File tree Expand file tree Collapse file tree 1 file changed +18
-7
lines changed
Expand file tree Collapse file tree 1 file changed +18
-7
lines changed Original file line number Diff line number Diff line change @@ -51,6 +51,21 @@ export interface AutocompleteOutcome extends TabAutocompleteOptions {
5151
5252const 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+
5469function 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 ( ) =>
You can’t perform that action at this time.
0 commit comments