Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
10 changes: 7 additions & 3 deletions core/autocomplete/completionProvider.ts
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@
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";
Expand Down Expand Up @@ -355,8 +355,12 @@
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;
}

Expand All @@ -364,7 +368,7 @@
const completionToCache = outcome.completion;
setTimeout(async () => {
if (!outcome.cacheHit) {
(await this.autocompleteCache).put(outcome.prefix, completionToCache);

Check warning on line 371 in core/autocomplete/completionProvider.ts

View workflow job for this annotation

GitHub Actions / tsc-check

Promises must be awaited, end with a call to .catch, end with a call to .then with a rejection handler or be explicitly marked as ignored with the `void` operator
}
}, 100);

Expand Down
6 changes: 3 additions & 3 deletions core/autocomplete/filter.ts
Original file line number Diff line number Diff line change
@@ -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);
}
15 changes: 15 additions & 0 deletions manual-testing-sandbox/Button.tsx
Original file line number Diff line number Diff line change
@@ -0,0 +1,15 @@
import React from "react";

export const Button = ({
onClick,
children,
}: {
children: React.ReactNode;
onClick: () => void;
}) => {
return (
<button className="btn btn-primary" onClick={onClick}>
{children}
</button>
);
};
Loading