sublime_text icon indicating copy to clipboard operation
sublime_text copied to clipboard

can no longer have multiple “Find in Files…” running at once

Open dcrousso opened this issue 3 years ago • 1 comments

Description

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...".

Steps to reproduce

  1. add the above code as a user plugin
  2. open a new window
  3. add a folder with lots of files (e.g. ~/Library) to the current project
  4. "Find in Files..." for "abc"
  5. "Find in Files..." for "def"

Expected behavior

two tabs, 'Find Results ("abc")' and 'Find Results ("def")', would be opened and "abc" would successfully finish first (i.e. no "Cancelled!")

Actual behavior

two tabs, 'Find Results ("abc")' and 'Find Results ("def")', would be opened but "abc" is "Cancelled!"

Environment

  • Build: 4107
  • Operating system and version: macOS 11

Miscellaneous

I also created a forum post in case anyone else was experiencing this and/or had a solution.

dcrousso avatar Jun 05 '21 01:06 dcrousso

I've had to switch back to ST3 because of this 😞

dcrousso avatar Nov 16 '21 20:11 dcrousso

Fixed in build 4148.

BenjaminSchaaf avatar Mar 14 '23 00:03 BenjaminSchaaf

@BenjaminSchaaf any idea when this is expected to ship in the regular (i.e. non-dev) release channel? i am eagerly awaiting this fix 😃

dcrousso avatar Jun 07 '23 20:06 dcrousso