Formatter issues
msftrncs opened this issue · comments
Carl Morris commented
The formatter (capitalizer) has a couple issues, and exposes a grammar issue.
TYPE Bob : (* test *) STRUCT
A, B : INT; //test
b : INT; //test
END_STRUCT
END_TYPE
(* Bool Word Struct Constant
Note there are multiple issues.
- It capitalized a broken comment. The comment doesn't end, and that lack of an end trips up the regex used to detect keywords, while ignoring comments and quoted strings.
- It thought the start of the comment was a parameter list for a function call or operator
END_TYPE
so it moved it. 'keywords' and the 'end' block keywords should be excluded from this treatment., - The TM grammar changed the scope of the keyword
END_TYPE
when it has a parenthesis behind it. SinceEND_TYPE
is a rigid keyword, it should appear very high in the processing in the grammar file, above anything that utilizes a more generic form.
The VAR_
keywords, but not VAR
or END_VAR
, seem to be missing from the capitalization behavior. This is not shown above.
Sergey Romanov commented
That is strange. Here is the code
let regEx = new RegExp(`\\b(?:${functions.join('|')})\\b\\s+\\(`, "ig");
It should move only functions.
The problem was in function
array. Last element was empty.
Sergey Romanov commented
Looks like VAR_*
is not considered at all. Also fixed that.
Sergey Romanov commented
New version released 1.9.1 with 2 fixes.