sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
803 stars 39 forks source link

Support multiple lines in build system's file_regex #1430

Open nh2 opened 7 years ago

nh2 commented 7 years ago

Some build systems output multiline errors, for example the GHC Haskell compiler:

/path/to/file.hs:86:22: warning: [-Wname-shadowing]
    This binding for ‘myvar’ shadows the existing binding
      imported from ‘My.Module’ at /path/to/file.hs:29:1-30
      (and originally defined
         at /path/to/file.hs:347:1-5)

Here, the error message is on the second line.

This cannot currently be parsed by Sublime's file_regex functionality in build systems, because apparently that regex does not support multiline.

It would be great if we could allow a multi-line file_regex to support errors like the above.

(see also https://forum.sublimetext.com/t/matching-multiline-build-system-output-file-regex/23414)

ismell commented 6 years ago

So this partially works for me. I can step through the errors using F4 in the results pane, but the errors don't show up overlayed on the actual file. Nor can I click on the filename in the results pane to navigate to the file:line:col.

friedbrice commented 5 years ago

I can confirm that the build system regex does not match multiple lines, using the following build definition.

{
  "selector": "source.haskell",
  "cmd": ["ghc", "-dynamic", "-fno-code", "$file"],
  "working_dir": "$file_path",
  "file_regex": "^(.*):(\\d+):(\\d+):.*\\n\\s*(.*)$"
}

Invoking the build fails to display errors, but when file_regex is changed to "^(.*):(\\d+):(\\d+):.*$" (removing the newline), invoking the build causes errors display as expected (albeit without the error message).

friedbrice commented 5 years ago

Here is the output I am trying to match:

sample-file.hs:12:26: error:
    Not in scope: type constructor or class ‘Messages’
    Perhaps you meant ‘Message’ (line 7)
   |
12 | makeMessage :: String -> Messages
   |                          ^^^^^^^^

My regex ^(.*):(\d+):(\d+):.*\n\s*(.*)$ works, according to https://regex101.com/

DopustimVladimir commented 2 years ago

It would be nice to see this fixed in the next release...

kenny-kvibe commented 2 years ago

+1 I've been trying to do exactly what this issue states but for Python error messages (here's a line_regex example that works, but not if added to file_regex) & it seems like line_regex does support multi-line capturing but its captures are not shown anywhere (possibly if not captured by file_regex first).