There’s not a config option for that, no; this mechanism is implemented using the same thing that allows you to double click on error messages in build results and have the file open at the given location. As such it’s triggered by specifically matching text, which in the case of Find in Files
is the lines that represent matches (which have a :
after their line number).
That said, you can get the behaviour you want with a plugin such as the following:
import sublime
import sublime_plugin
import bisect
import re
def handle_double_click(view, point):
"""
Handle a double click at the given point in the buffer; if the click is in
a context line, trigger an open of the file on that line. For any other
location, do nothing and let the default action occur.
"""
line = view.substr(view.line(point))
match = re.search(r"^\s+(\d)+ ", line)
if match:
file_list = view.find_by_selector('entity.name.filename')
line = int(match.group(0))
file_idx = bisect.bisect(file_list, sublime.Region(point)) - 1
filename = "{}:{}".format(view.substr(file_list[file_idx]), line)
view.window().open_file(filename, sublime.ENCODED_POSITION)
return ("noop")
return None
class EnhancedFindInFilesListener(sublime_plugin.ViewEventListener):
@classmethod
def is_applicable(cls, settings):
return 'Find Results.hidden-tmLanguage' in settings.get('syntax')
def on_text_command(self, command, args):
if command == "drag_select" and args.get("by", None) == "words":
event = args.get('event')
point = self.view.window_to_text((event["x"], event["y"]))
return handle_double_click(self.view, point)
This watches for double click actions in Find in Files
results, and if the double click is on one of the context lines, the file will open on that line. See this video on how to use plugins if you’re not sure how to put the plugin in place.
There may also be packages available that do this on Package Control as well.