Sublime Forum

Capturing group order for result_file_regex

#1

When parsing errors such as error 2 in line 1741 of "src/Wonderland.s": unknown mnemonic <dasdvx> I’m currently using this regular expression in my panel’s result_file_regex:

panel_settings.set('result_file_regex', r'^error (?:\d+) in line (\d+) of "([^"]+)": (.+)$')

which captures all the right bits but in the wrong order (clicking on the error tries to open the file 1741).

How do I control the order in which Sublime Text parses the regex’s results?

(this was already asked here and here but never got any answers)

0 Likes

#2

I’ve made some progress by getting some help from the internet and then found that my solution was already mentioned in this issue.

Basically since the capture order is hard coded in Sublime Text, you have to use look ahead capture groups in order (pun not intended) to move the captured values alround. I ended up with:

panel_settings.set('result_file_regex', r'^error \d+ in line (?=\d+ of "([^"]+)")(\d+)() of "[^"]+": (.+)$')

This also has an empty capture group () in order to skip the missing column number in my error message.

I’m now able to click on the error and get to the correct file and line in the editor but I don’t see anything displaying the error message inline in the window when I hover over the line.

Is this normal? Am I missing something in order for the error message to display in the editor window itself?

0 Likes

#3

Does anyone know what is supposed to happen with the fourth capture here (the error message itself)?

It doesn’t seem to display it inline in the editor window. What does Sublime Text do with this?

0 Likes