Skip to content

Commit 68ca204

Browse files
committed
Merge branch 'lmaosweqf1-patch-1' into preview
2 parents a253e7c + f86016b commit 68ca204

File tree

1 file changed

+18
-7
lines changed

1 file changed

+18
-7
lines changed

core/autocomplete/completionProvider.ts

Lines changed: 18 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -51,6 +51,21 @@ export interface AutocompleteOutcome extends TabAutocompleteOptions {
5151

5252
const autocompleteCache = AutocompleteLruCache.get();
5353

54+
const DOUBLE_NEWLINE = "\n\n";
55+
const WINDOWS_DOUBLE_NEWLINE = "\r\n\r\n";
56+
const SRC_DIRECTORY = "/src/";
57+
const STARCODER2_T_ARTIFACT = "t.";
58+
const PYTHON_ENCODING = "#- coding: utf-8";
59+
const CODE_BLOCK_END = "```";
60+
61+
const multilineStops = [DOUBLE_NEWLINE, WINDOWS_DOUBLE_NEWLINE];
62+
const commonStops = [
63+
SRC_DIRECTORY,
64+
STARCODER2_T_ARTIFACT,
65+
PYTHON_ENCODING,
66+
CODE_BLOCK_END,
67+
];
68+
5469
function formatExternalSnippet(
5570
filepath: string,
5671
snippet: string,
@@ -204,22 +219,18 @@ export async function getTabCompletion(
204219
cacheHit = true;
205220
completion = cachedCompletion;
206221
} else {
207-
// Try to reuse pending requests if what the user typed matches start of completion
208222
let stop = [
209223
...(completionOptions?.stop || []),
210-
"\n\n",
211-
// The following are commonly appended to completions by starcoder and other models
212-
"/src/",
213-
"t.",
214-
"#- coding: utf-8",
215-
"```",
224+
...multilineStops,
225+
...commonStops,
216226
...lang.stopWords,
217227
];
218228

219229
const multiline =
220230
options.multilineCompletions !== "never" &&
221231
(options.multilineCompletions === "always" || completeMultiline);
222232

233+
// Try to reuse pending requests if what the user typed matches start of completion
223234
let generator = generatorReuseManager.getGenerator(
224235
prefix,
225236
() =>

0 commit comments

Comments
 (0)