Sublime Forum

Matching multiline build system output file_regex

#1

In Sublime Text 3, I’m try to write a file_regex to capture the following error message:

/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)

File, column and line are easy, but how do I capture the error message (This binding for ‘myvar’ shadows the existing binding) which is on the second line?

I’m having trouble with it because file_regex doesn’t seem to support multi-line regexes.

What can I do?

0 Likes

#2

What is your regex? May you run it on: https://regex101.com/r/vxGIEc/2

0 Likes

#3

Well I’m trying with ^(\S*):(\d+):(\d+):.*\n(.*).

That works in the site you linked, but not in file_regex.

0 Likes

#4

This looks related with this issue:

  1. Core/issues/1412 _ A native to apply a scope give a chunk of text

May be opening a new issue, requesting to the file_regex allow to match one or two lines.

0 Likes

#5

OK, thank you. I filed it at https://github.com/SublimeTextIssues/Core/issues/1430

0 Likes

#6

A more simple solution would be to add a 3 regex: “message_regex” in addition to the “file_regex” and “line_regex”.

I mentioned it in API Suggestions

2 Likes