improv: preserve punctuation completions
This commit is contained in:
parent
d213b395c9
commit
50515b7fd8
3 changed files with 25 additions and 6 deletions
|
|
@ -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;
|
||||
}
|
||||
|
||||
|
|
|
|||
|
|
@ -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
manual-testing-sandbox/Button.tsx
Normal file
15
manual-testing-sandbox/Button.tsx
Normal file
|
|
@ -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…
Add table
Reference in a new issue