From 598cd40016020482b318466e9f84be704e6beaa9 Mon Sep 17 00:00:00 2001 From: Nate Sesti Date: Fri, 23 Feb 2024 07:23:44 -0800 Subject: [PATCH] =?UTF-8?q?=F0=9F=94=A7=20add=20option=20to=20always=20ena?= =?UTF-8?q?ble=20multiline=20completions?= MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- core/index.d.ts | 2 +- docs/docs/walkthroughs/tab-autocomplete.md | 1 + extensions/vscode/config_schema.json | 4 ++-- extensions/vscode/src/lang-server/completionProvider.ts | 5 ++++- 4 files changed, 8 insertions(+), 4 deletions(-) diff --git a/core/index.d.ts b/core/index.d.ts index 261081593..9882b8d55 100644 --- a/core/index.d.ts +++ b/core/index.d.ts @@ -581,7 +581,7 @@ export interface TabAutocompleteOptions { maxSuffixPercentage: number; prefixPercentage: number; template?: string; - disableMultiLineCompletions?: boolean; + multilineCompletions?: "always" | "never" | "auto"; } export interface SerializedContinueConfig { diff --git a/docs/docs/walkthroughs/tab-autocomplete.md b/docs/docs/walkthroughs/tab-autocomplete.md index 6579a21a1..ea4f6f36f 100644 --- a/docs/docs/walkthroughs/tab-autocomplete.md +++ b/docs/docs/walkthroughs/tab-autocomplete.md @@ -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 diff --git a/extensions/vscode/config_schema.json b/extensions/vscode/config_schema.json index e37574e2b..832dcbc59 100644 --- a/extensions/vscode/config_schema.json +++ b/extensions/vscode/config_schema.json @@ -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." } }, diff --git a/extensions/vscode/src/lang-server/completionProvider.ts b/extensions/vscode/src/lang-server/completionProvider.ts index bf6d22ccc..c78ec8921 100644 --- a/extensions/vscode/src/lang-server/completionProvider.ts +++ b/extensions/vscode/src/lang-server/completionProvider.ts @@ -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, () =>