🔧 add option to always enable multiline completions

This commit is contained in:
Nate Sesti 2024-02-23 07:23:44 -08:00
parent c762604fa3
commit 598cd40016
4 changed files with 8 additions and 4 deletions

2
core/index.d.ts vendored
View file

@ -581,7 +581,7 @@ export interface TabAutocompleteOptions {
maxSuffixPercentage: number;
prefixPercentage: number;
template?: string;
disableMultiLineCompletions?: boolean;
multilineCompletions?: "always" | "never" | "auto";
}
export interface SerializedContinueConfig {

View file

@ -49,6 +49,7 @@ This object allows you to customize the behavior of tab-autocomplete. The availa
- `maxSuffixPercentage`: The maximum percentage of the prompt that can be dedicated to the suffix. (Number)
- `prefixPercentage`: The percentage of the input that should be dedicated to the prefix. (Number)
- `template`: An optional template string to be used for autocomplete. It will be rendered with the Mustache templating language, and is passed the 'prefix' and 'suffix' variables. (String)
- `multilineCompletions`: Whether to enable multiline completions ("always", "never", or "auto"). Defaults to "auto".
### Full example

View file

@ -1436,8 +1436,8 @@
"type": "string",
"description": "An optional template string to be used for autocomplete. It will be rendered with the Mustache templating language, and is passed the 'prefix' and 'suffix' variables."
},
"disableMultiLineCompletions": {
"type": "boolean",
"multilineCompletions": {
"enum": ["always", "never", "auto"],
"description": "If set to true, Continue will only complete a single line at a time."
}
},

View file

@ -311,7 +311,10 @@ async function getTabCompletion(
"```",
...lang.stopWords,
];
if (options.disableMultiLineCompletions || !completeMultiline) {
if (
options.multilineCompletions !== "always" &&
(options.multilineCompletions === "never" || !completeMultiline)
) {
stop.unshift("\n");
}
let generator = GeneratorReuseManager.getGenerator(prefix, () =>