tree-sitter / tree-sitter-typescript

TypeScript grammar for tree-sitter
MIT License
332 stars 103 forks source link

Parsing error on ANSI escape codes #272

Closed bartosz-k closed 5 months ago

bartosz-k commented 6 months ago

The following piece of code is valid but it is parsed incorrectly:

const highlight = (text: string) => `\x1b[1m${text}\x1b[0m`;
const dim = (text: string) => `\x1b[2m${text}\x1b[0m`;
const error = (text: string) => `\x1b[91m${text}\x1b[0m`;

Here's a link to the TypeScript Playground showing that the snippet above is valid JavaScript or TypeScript: https://www.typescriptlang.org/play?#code/MYewdgzgLgBAFgSwOZwDbLrAvDAFFAUwA8oAuGaAJwTCQEoYsA+GAAwB0iBGAIwG0uAWwAkAb0IkAvp158ADINYBuAFChIsACYJBjPBLIUo1Wg2ZsZ-AEwjxxKNO78FyteGgwClSiEp789uRUNPSMLBxOfACcQmIGjrIuSkA

The symptom is broken highlighting in neovim:

image