From 862fa13002d8018c328931ee1edccfd4ca76447d Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Tue, 25 Jul 2023 16:03:17 -0700 Subject: [PATCH] Don't add auto-executing slash commands to input (#188866) --- .../contrib/chat/browser/actions/chatExecuteActions.ts | 3 ++- .../contrib/chat/browser/contrib/chatInputEditorContrib.ts | 4 ++-- 2 files changed, 4 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts b/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts index 10a24bd4b4b..7f639db3aeb 100644 --- a/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts +++ b/src/vs/workbench/contrib/chat/browser/actions/chatExecuteActions.ts @@ -14,6 +14,7 @@ import { IChatService } from 'vs/workbench/contrib/chat/common/chatService'; export interface IChatExecuteActionContext { widget: IChatWidget; + inputValue?: string; } function isExecuteActionContext(thing: unknown): thing is IChatExecuteActionContext { @@ -48,7 +49,7 @@ export class SubmitAction extends Action2 { return; } - context.widget.acceptInput(); + context.widget.acceptInput(context.inputValue); } } diff --git a/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts b/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts index da99185ded1..5cf1bfd36e3 100644 --- a/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts +++ b/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts @@ -229,12 +229,12 @@ class SlashCommandCompletions extends Disposable { const withSlash = `/${c.command}`; return { label: withSlash, - insertText: `${withSlash} `, + insertText: c.executeImmediately ? '' : `${withSlash} `, detail: c.detail, range: new Range(1, 1, 1, 1), sortText: c.sortText ?? c.command, kind: CompletionItemKind.Text, // The icons are disabled here anyway, - command: c.executeImmediately ? { id: SubmitAction.ID, title: withSlash, arguments: [{ widget }] } : undefined, + command: c.executeImmediately ? { id: SubmitAction.ID, title: withSlash, arguments: [{ widget, inputValue: withSlash }] } : undefined, }; }) };