diff --git a/src/editor/lsp/semantic/python/highlight.test.ts b/src/editor/lsp/semantic/python/highlight.test.ts index b44f4a0d69..e700814533 100644 --- a/src/editor/lsp/semantic/python/highlight.test.ts +++ b/src/editor/lsp/semantic/python/highlight.test.ts @@ -12,6 +12,15 @@ async function parse(source: string) { } describe("Python PyCharm categories", () => { + it.each(["async def ():\n ", "def ():\n ", "class :\n "])( + "does not color zero-width recovery nodes in %j", + async (source) => { + const { tree, doc } = await parse(source); + const ranges = [...pythonSyntaxRanges(tree, doc), ...pythonFallbackRanges(tree, doc)]; + expect(ranges.filter((range) => range.from >= range.to)).toEqual([]); + }, + ); + it("uses the completed tree when initial parsing exceeds its time budget", async () => { await parse(""); // Exceed the initial 20 ms parse budget, but stay within ensureSyntaxTree's budget. diff --git a/src/editor/lsp/semantic/python/highlight.ts b/src/editor/lsp/semantic/python/highlight.ts index a7158e43b2..23b8830f2a 100644 --- a/src/editor/lsp/semantic/python/highlight.ts +++ b/src/editor/lsp/semantic/python/highlight.ts @@ -459,6 +459,7 @@ export function pythonSymbolKinds(tree: Tree, doc: Text): Map