From 2e615c0542cea8d9a1da65f7cf526df1de165cc2 Mon Sep 17 00:00:00 2001 From: Joyce Er Date: Wed, 19 Jul 2023 10:13:39 -0700 Subject: [PATCH] Announce chat slash command deletion (#188215) * Announce chat slash command deletion * Fix localization formatting --- .../contrib/chat/browser/chatSlashCommandContentWidget.ts | 7 ++++++- .../contrib/chat/browser/contrib/chatInputEditorContrib.ts | 4 +++- .../contrib/inlineChat/browser/inlineChatWidget.ts | 2 +- 3 files changed, 10 insertions(+), 3 deletions(-) diff --git a/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.ts b/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.ts index a2fa834d905..51324840b88 100644 --- a/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.ts +++ b/src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.ts @@ -9,12 +9,14 @@ import { Range } from 'vs/editor/common/core/range'; import { Disposable } from 'vs/base/common/lifecycle'; import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget } from 'vs/editor/browser/editorBrowser'; import { KeyCode } from 'vs/base/common/keyCodes'; +import { localize } from 'vs/nls'; +import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; export class SlashCommandContentWidget extends Disposable implements IContentWidget { private _domNode = document.createElement('div'); private _lastSlashCommandText: string | undefined; - constructor(private _editor: ICodeEditor) { + constructor(private _editor: ICodeEditor, private _accessibilityService: IAccessibilityService) { super(); this._domNode.toggleAttribute('hidden', true); @@ -65,5 +67,8 @@ export class SlashCommandContentWidget extends Disposable implements IContentWid range: new Range(1, 1, 1, selection.startColumn), text: null }]); + + // Announce the deletion + this._accessibilityService.alert(localize('exited slash command mode', 'Exited {0} mode', this._lastSlashCommandText)); } } diff --git a/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts b/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts index 80d2c1989f1..da99185ded1 100644 --- a/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts +++ b/src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts @@ -24,6 +24,7 @@ import { ChatInputPart } from 'vs/workbench/contrib/chat/browser/chatInputPart'; import { IChatService } from 'vs/workbench/contrib/chat/common/chatService'; import { SlashCommandContentWidget } from 'vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget'; import { SubmitAction } from 'vs/workbench/contrib/chat/browser/actions/chatExecuteActions'; +import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility'; const decorationDescription = 'chat'; const slashCommandPlaceholderDecorationType = 'chat-session-detail'; @@ -39,6 +40,7 @@ class InputEditorDecorations extends Disposable { @ICodeEditorService private readonly codeEditorService: ICodeEditorService, @IThemeService private readonly themeService: IThemeService, @IChatService private readonly chatService: IChatService, + @IAccessibilityService private readonly accessibilityService: IAccessibilityService, ) { super(); @@ -139,7 +141,7 @@ class InputEditorDecorations extends Disposable { if (command && inputValue.startsWith(`/${command.command} `)) { if (!this._slashCommandContentWidget) { - this._slashCommandContentWidget = new SlashCommandContentWidget(this.widget.inputEditor); + this._slashCommandContentWidget = new SlashCommandContentWidget(this.widget.inputEditor, this.accessibilityService); this._store.add(this._slashCommandContentWidget); } this._slashCommandContentWidget.setCommandText(command.command); diff --git a/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts b/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts index b0cc6198c47..28f192ef209 100644 --- a/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts +++ b/src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts @@ -286,7 +286,7 @@ export class InlineChatWidget { // slash command content widget - this._slashCommandContentWidget = new SlashCommandContentWidget(this._inputEditor); + this._slashCommandContentWidget = new SlashCommandContentWidget(this._inputEditor, this._accessibilityService); this._store.add(this._slashCommandContentWidget); // toolbars