Sublime Forum

Find Results files: a way to open it after it was saved?

#1

Hi,

Is there a standard straight way to reopen a “Find Results”, after it was saved as a file? When I do, it is reopen as a raw text file, and I noticed the “Find Results” language syntax is an hidden syntax.

Or else, is there a standard way with Sublime Text, to have a file with locations to other files?

Is there is no, I don"t mind, I will start a plug‑in for this a future day. Just that I miss it, it’s convenient, and I would like the get something similar using a regular file.

0 Likes

#2

You have to set the syntax with plugin code.

It should also be possible to associate an extension with the Find Results syntax (untested). You’ll need to open a view with that syntax, then open the syntax-specific User settings and add "extensions": "fres"] to it, or whatever your extension is.

0 Likes

#3

I just tested and it does not work, it still opens as Plain Text.

From the console, I tried this:

view = sublime.active_window().active_view()
view.set_syntax_file("Packages/Default/Find Results.hidden-tmLanguage")

It’s OK for the syntax highlight and the language, but not for the behavior: double clicking on a line does not open the location.

— Edit —

./sublime_text --help
Sublime Text build 3083

Usage: sublime_text [arguments] [files]         edit the given files
   or: sublime_text [arguments] [directories]   open the given directories

Arguments:
…]

Filenames may be given a :line or :line:column suffix to open at a specific
location.

At least, there is a way to open a location from the command‑line. I will try this way.

0 Likes

#4

Oh, I didn’t realize this is what you wanted, although it makes sense from your initial post. Add this to your plugin code (which I read from a find results view):

view.settings().set('result_line_regex', '^ +([0-9]+):') view.settings().set('result_file_regex', '^([A-Za-z\\\\/<].*):$')

You can also alter these expressions and use a custom syntax, if you prefer. They follow the same rules as those for build result output panels: docs.sublimetext.info/en/latest/ … ror-output (which needs to be reworded, as I just saw)

0 Likes

#5

I did not suspect result_file_regex was intended to work on any view, I though this was for the build result panel only. Thanks for the tip.

Unfortunately, when I double click on a line, I now get a crash (tried two times).

By the way, the crashes I get, seems all related to regular expressions. Either the regex library is buggy or Sublime Text do something wrong with it.

0 Likes

#6

Could you share your code and sample file so I could try to reproduce?

0 Likes

#7

I open this file: Find Results.zip (can’t attach file on the forum, so I put it there).
With this view as the active view, from the console I do:

view = sublime.active_window().active_view() view.settings().set('result_line_regex', '^ +([0-9]+):') view.settings().set('result_file_regex', '^([A-Za-z\\\\/<].*):$')
Then in the view containing the Find Results file, I double click a result line, like “ 87: dataprop Q(i:int)”. At that moment, it crashes.

0 Likes

#8

#worksforme

What’s your OS? I tested this on Windows 7.

Btw, view in the console automatially refers to the active view, just like window refers to the active window.

Another btw, output views are really “just views” with certain initial settings. They can behave a bit odd (most notably when you enable the gutter, iirc), but other than that they are pretty much just view. As are input panels, or the inputs in the find panel, or the quick panel, or goto anything, or the command palette.

0 Likes

#9

[quote=“FichteFoll”]#worksforme

What’s your OS? I tested this on Windows 7.
…][/quote]

Ubuntu 14.04, 32 bits. Sublime Text build 3083.

0 Likes

#10

If ever this can help, here is for the executable dependencies:

ldd ./sublime_text
    linux-gate.so.1 =>  (0xb774f000)
    libgobject-2.0.so.0 => /usr/lib/i386-linux-gnu/libgobject-2.0.so.0 (0xb76e0000)
    librt.so.1 => /lib/i386-linux-gnu/librt.so.1 (0xb76d7000)
    libglib-2.0.so.0 => /lib/i386-linux-gnu/libglib-2.0.so.0 (0xb75ca000)
    libpthread.so.0 => /lib/i386-linux-gnu/libpthread.so.0 (0xb75ae000)
    libdl.so.2 => /lib/i386-linux-gnu/libdl.so.2 (0xb75a9000)
    libX11.so.6 => /usr/lib/i386-linux-gnu/libX11.so.6 (0xb7475000)
    libm.so.6 => /lib/i386-linux-gnu/libm.so.6 (0xb742f000)
    libc.so.6 => /lib/i386-linux-gnu/libc.so.6 (0xb7280000)
    /lib/ld-linux.so.2 (0xb7750000)
    libffi.so.6 => /usr/lib/i386-linux-gnu/libffi.so.6 (0xb7279000)
    libpcre.so.3 => /lib/i386-linux-gnu/libpcre.so.3 (0xb723b000)
    libxcb.so.1 => /usr/lib/i386-linux-gnu/libxcb.so.1 (0xb7219000)
    libXau.so.6 => /usr/lib/i386-linux-gnu/libXau.so.6 (0xb7215000)
    libXdmcp.so.6 => /usr/lib/i386-linux-gnu/libXdmcp.so.6 (0xb720d000)
0 Likes