From 8187e0d39a06c9e57fc9df682ce02ad9cbb97b84 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Sat, 2 Mar 2024 21:28:23 -0500 Subject: [PATCH] =?UTF-8?q?=F0=9F=90=9B=20don't=20try=20to=20calculate=20A?= =?UTF-8?q?ST=20in=20non-code=20files?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/autocomplete/constructPrompt.ts | 2 +- core/autocomplete/lineStream.ts | 4 ++++ 2 files changed, 5 insertions(+), 1 deletion(-) diff --git a/core/autocomplete/constructPrompt.ts b/core/autocomplete/constructPrompt.ts index 9ba4083c3..85bd3c54a 100644 --- a/core/autocomplete/constructPrompt.ts +++ b/core/autocomplete/constructPrompt.ts @@ -80,7 +80,7 @@ async function shouldCompleteMultiline( try { const ast = await getAst(filepath, fullPrefix + fullSuffix); if (!ast) { - throw new Error(`AST undefined for ${filepath}`); + return true; } treePath = await getTreePathAtCursor(ast, fullPrefix.length); diff --git a/core/autocomplete/lineStream.ts b/core/autocomplete/lineStream.ts index 76ea3e01d..c7ecc2f7c 100644 --- a/core/autocomplete/lineStream.ts +++ b/core/autocomplete/lineStream.ts @@ -243,4 +243,8 @@ export async function* stopAtRepeatingLines(lines: LineStream): LineStream { return; } } + + while (repeatedLines.length > 0) { + yield repeatedLines.shift()!; + } }