Sublime Forum

ST4: can no longer have multiple "Find in Files..." running at once

#1

The main project I work on has a pattern where code that flows from C++ to ObjC (and vice versa) will have the same function name to make it easier to search through code. As an example, there could be a void Class::foo(int bar) in C++ and - (void)foo:(int)bar in ObjC. In order to fully find all callsites of any variant of foo in the code I’d often “Find in Files…” twice in rapid succession, once for .foo( (and/or ->foo() and once for foo: (with a leading space). In order to do this I also had a very small local plugin that caused each “Find in Files…” to create a new tab:

import re
import sublime
import sublime_plugin

s_views = []

def s_updateViewName(view):
    contents = view.substr(sublime.Region(0, view.size()))
    contents = contents.replace("\n", "\\n")
    match = re.search("^Searching \d+ files for \"(.*)\"(?:\s|\\\\n|$)", contents)
    if match:
        view.set_name("Find Results (\"" + match.group(1) + "\")")
    else:
        view.set_name("Find Results (\"\")")

class UniqueFindBufferEventListener(sublime_plugin.EventListener):
    def on_activated_async(self, view):
        if view.name() != "Find Results":
            return

        s_updateViewName(view)
        s_views.append(view)

    def on_modified_async(self, view):
        if view not in s_views:
            return

        s_updateViewName(view)
        s_views.remove(view)

After upgrading to ST4 I now see “Cancelled!” in the first find tab. Is there a setting to control this so that starting another “Find in Files…” doesn’t cancel a prior one? This is also problematic in situations like if I realize that my first “Find in Files…” was misspelled, start a new “Find in Files…” with the right spelling, and then close the first tab for the first incorrectly spelled “Find in Files…”.

0 Likes

#2

I’ve had to switch back to ST3 because of this :disappointed:

0 Likes

#3

I’ve just copied this plugin into ST4 Build 4126 and it works perfectly for me.

0 Likes

#4

I just tried ST4 Build 4126 and I’m still seeing the same issue.

Note that this is not a problem if the first “Find in Files…” completes before any other “Find in Files…” are started (i.e. it’s only a problem if the first “Find in Files…” takes long enough that you can start a second “Find in Files…” before the first finishes). This is avoidable if you add a very large folder to the current project/workspace (which is what I do since the project I work on is very large).

0 Likes