-
Notifications
You must be signed in to change notification settings - Fork 42
Show Name of Undefined Control Sequence (macro) #496
Conversation
When LaTeX complains about undefined control sequence, this plugin does not show the name of said macro, which is what this commit attempts to fix.
…x into control-sequence-name
Also changed `var`s to `let` in log-parser.js
// Pattern for obtaining the last macro in a line | ||
// Meant for catching the undefined control sequence | ||
const LAST_MACRO_PATTERN = new RegExp('' + | ||
'(\\\\[^\\\\]+)$' // Macro name |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I'm not highly confident as to what ideally should a legal macro name in
this setting.
The problem is that the escape character, \
by default, can be redefined, as well
as having anything being active letters (and thus treated as control sequences)
E.g. doing
\catcode`O=13\relax O
would make the letter O an unknown control sequence, and
\catcode`J=0\relax JUndefined
would make JUnedfined
behave identically to \Undefined
and this atom plugin
will report weird information.
You can't just look at the last space and go from there. If you consider
{}\some@undef@macro
Then the {}
would be a part of the macro name reported by atom-latex.
However, I do argue that these cases are extraordinary circumstances,
and isn't really that necessary to implement.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would really love it if we had a test covering this. The easiest way would probably be to use one of the log files in the fixtures folder (e.g. file.log
) and augment it to contain an undefined control sequence error. Alternatively create a file which produces that error, and alter the locally generated log file by censoring local file paths, etc, like we've done for existing fixtures.
Having a test covering at least the "happy path" of this new logic ensures correct behavior, guards against regressions, and what not. Having tests that cover cases where a macro is not found would be amazing, but not strictly required.
When LaTeX complains about undefined control sequence, this plugin does not show the name of said macro, which is what this commit attempts to fix.
Also changed `var`s to `let` in log-parser.js
…x into control-sequence-name
I'll see if I get the time. |
Due to continuously timing out the test on this, I added a longer timeout. This is now removed per request: thomasjo#496 (comment)
- const where const is due - Better variable names - More canonical inline variables in string Also a few extra comments
As per review request, now checking that there exists at least one line below "Unknown control sequence" error before starting to parse it.
When LaTeX complains about undefined control sequence, this plugin does
not show the name of said macro, which is what this commit attempts to
fix.