Update completionProvider.ts

as @rootedbox suggested
This commit is contained in:
lmaosweqf1 2024-04-04 10:24:23 +03:00 • committed by GitHub
parent 91846d7181
commit 26c2f2fc9b
No known key found for this signature in database
GPG key ID: B5690EEEBB952194

View file

@ -203,13 +203,20 @@ export async function getTabCompletion(
cacheHit = true;
completion = cachedCompletion;
} else {
// Try to reuse pending requests if what the user typed matches start of completion
const DOUBLE_NEWLINE = "\n\n";
const WINDOWS_DOUBLE_NEWLINE = "\r\n\r\n";
const SRC_DIRECTORY = "/src/";
const T_FILE_EXTENSION = ".t.";
const PYTHON_ENCODING = "#- coding: utf-8";
const CODE_BLOCK_END = "```";
const multilineStops = [DOUBLE_NEWLINE, WINDOWS_DOUBLE_NEWLINE];
const commonStops = [SRC_DIRECTORY, T_FILE_EXTENSION, PYTHON_ENCODING, CODE_BLOCK_END];
let stop = [
...(completionOptions?.stop || []),
"\n\n",
"\r\n\r\n",
"/src/",
"```",
...multilineStops,
...commonStops,
...lang.stopWords,
];
@ -217,6 +224,7 @@ export async function getTabCompletion(
options.multilineCompletions !== "never" &&
(options.multilineCompletions === "always" || completeMultiline);
// Try to reuse pending requests if what the user typed matches start of completion
let generator = generatorReuseManager.getGenerator(
prefix,
() =>