rosshamish / kuskus

The extension pack so nice they named it twice
https://marketplace.visualstudio.com/items?itemName=rosshamish.kuskus-extensions-pack
45 stars 11 forks source link

Strings ending in "\\" break syntax highlighting #94

Open joshuacc opened 2 years ago

joshuacc commented 2 years ago

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

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

image

rosshamish commented 2 years ago

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 commented 2 years ago

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