diff --git a/core/autocomplete/completionProvider.ts b/core/autocomplete/completionProvider.ts index d954c3f31..bc826f934 100644 --- a/core/autocomplete/completionProvider.ts +++ b/core/autocomplete/completionProvider.ts @@ -28,7 +28,7 @@ import { constructAutocompletePrompt, languageForFilepath, } from "./constructPrompt.js"; -import { isOnlyPunctuationAndWhitespace } from "./filter.js"; +import { isOnlyWhitespace } from "./filter.js"; import { AutocompleteLanguageInfo } from "./languages.js"; import { postprocessCompletion } from "./postprocessing.js"; import { AutocompleteSnippet } from "./ranking.js"; @@ -355,8 +355,12 @@ export class CompletionProvider { return undefined; } - // Filter out unwanted results - if (isOnlyPunctuationAndWhitespace(outcome.completion)) { + /** + * This check is most likely not needed because we do trim the LLM output + * elsewhere in the code. That said, I'm not yet confident enough to + * remove this. + */ + if (isOnlyWhitespace(outcome.completion)) { return undefined; } diff --git a/core/autocomplete/filter.ts b/core/autocomplete/filter.ts index 9fb9b7d0b..5b2b66df0 100644 --- a/core/autocomplete/filter.ts +++ b/core/autocomplete/filter.ts @@ -1,4 +1,4 @@ -export function isOnlyPunctuationAndWhitespace(completion: string): boolean { - const punctuationAndWhitespaceRegex = /^[^\w\d\}\)\]]+$/; - return punctuationAndWhitespaceRegex.test(completion); +export function isOnlyWhitespace(completion: string): boolean { + const whitespaceRegex = /^[\s]+$/; + return whitespaceRegex.test(completion); } diff --git a/manual-testing-sandbox/Button.tsx b/manual-testing-sandbox/Button.tsx new file mode 100644 index 000000000..4d6f8f91b --- /dev/null +++ b/manual-testing-sandbox/Button.tsx @@ -0,0 +1,15 @@ +import React from "react"; + +export const Button = ({ + onClick, + children, +}: { + children: React.ReactNode; + onClick: () => void; +}) => { + return ( + + ); +};