kuskus icon indicating copy to clipboard operation
kuskus copied to clipboard

Strings ending in "\\" break syntax highlighting

Open joshuacc opened this issue 3 years ago • 2 comments

The following is syntactically correct code, but it breaks syntax highlighting.

let myVar = "a\\";
let myOtherVar = "whatever";

image

joshuacc avatar Oct 17 '22 17:10 joshuacc

Thanks for the report. I'll try to take a look at some point. If any other contributors want to take a stab at this, it should be some regex change in the tmlanguage file.

rosshamish avatar Oct 17 '22 18:10 rosshamish

Looks like the Escapes section of the tmLanguage.yml needs to be updated to allow for other escape sequences. Currently it suports escaping single and double quotes. Needs \t, \n, \\. We can add a test case in kusto-syntax-highlighting\test\snapshots\data-types\strings.kql to cover this by putting a \\ at the end of the string on line 22.

tmLanguage.yml, currently:

  Escapes:
    patterns:
      - match: \\['"]
        name: constant.character.escape.kusto

Proposed fix:

  Escapes:
    patterns:
      - match: \\['"tn\\]
        name: constant.character.escape.kusto

and then

  1. npm run convert to convert the yml to json
  2. npm run test to check that the tests look right
  3. npm run test:update-snapshot to update the snapshots

rosshamish avatar Oct 17 '22 22:10 rosshamish