Skip to content

Commit 2e615c0

Browse files
authored
Announce chat slash command deletion (microsoft#188215)
* Announce chat slash command deletion * Fix localization formatting
1 parent 37c5709 commit 2e615c0

File tree

3 files changed

+10
-3
lines changed

3 files changed

+10
-3
lines changed

src/vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget.ts

Lines changed: 6 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -9,12 +9,14 @@ import { Range } from 'vs/editor/common/core/range';
99
import { Disposable } from 'vs/base/common/lifecycle';
1010
import { ContentWidgetPositionPreference, ICodeEditor, IContentWidget } from 'vs/editor/browser/editorBrowser';
1111
import { KeyCode } from 'vs/base/common/keyCodes';
12+
import { localize } from 'vs/nls';
13+
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
1214

1315
export class SlashCommandContentWidget extends Disposable implements IContentWidget {
1416
private _domNode = document.createElement('div');
1517
private _lastSlashCommandText: string | undefined;
1618

17-
constructor(private _editor: ICodeEditor) {
19+
constructor(private _editor: ICodeEditor, private _accessibilityService: IAccessibilityService) {
1820
super();
1921

2022
this._domNode.toggleAttribute('hidden', true);
@@ -65,5 +67,8 @@ export class SlashCommandContentWidget extends Disposable implements IContentWid
6567
range: new Range(1, 1, 1, selection.startColumn),
6668
text: null
6769
}]);
70+
71+
// Announce the deletion
72+
this._accessibilityService.alert(localize('exited slash command mode', 'Exited {0} mode', this._lastSlashCommandText));
6873
}
6974
}

src/vs/workbench/contrib/chat/browser/contrib/chatInputEditorContrib.ts

Lines changed: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -24,6 +24,7 @@ import { ChatInputPart } from 'vs/workbench/contrib/chat/browser/chatInputPart';
2424
import { IChatService } from 'vs/workbench/contrib/chat/common/chatService';
2525
import { SlashCommandContentWidget } from 'vs/workbench/contrib/chat/browser/chatSlashCommandContentWidget';
2626
import { SubmitAction } from 'vs/workbench/contrib/chat/browser/actions/chatExecuteActions';
27+
import { IAccessibilityService } from 'vs/platform/accessibility/common/accessibility';
2728

2829
const decorationDescription = 'chat';
2930
const slashCommandPlaceholderDecorationType = 'chat-session-detail';
@@ -39,6 +40,7 @@ class InputEditorDecorations extends Disposable {
3940
@ICodeEditorService private readonly codeEditorService: ICodeEditorService,
4041
@IThemeService private readonly themeService: IThemeService,
4142
@IChatService private readonly chatService: IChatService,
43+
@IAccessibilityService private readonly accessibilityService: IAccessibilityService,
4244
) {
4345
super();
4446

@@ -139,7 +141,7 @@ class InputEditorDecorations extends Disposable {
139141

140142
if (command && inputValue.startsWith(`/${command.command} `)) {
141143
if (!this._slashCommandContentWidget) {
142-
this._slashCommandContentWidget = new SlashCommandContentWidget(this.widget.inputEditor);
144+
this._slashCommandContentWidget = new SlashCommandContentWidget(this.widget.inputEditor, this.accessibilityService);
143145
this._store.add(this._slashCommandContentWidget);
144146
}
145147
this._slashCommandContentWidget.setCommandText(command.command);

src/vs/workbench/contrib/inlineChat/browser/inlineChatWidget.ts

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -286,7 +286,7 @@ export class InlineChatWidget {
286286

287287
// slash command content widget
288288

289-
this._slashCommandContentWidget = new SlashCommandContentWidget(this._inputEditor);
289+
this._slashCommandContentWidget = new SlashCommandContentWidget(this._inputEditor, this._accessibilityService);
290290
this._store.add(this._slashCommandContentWidget);
291291

292292
// toolbars

0 commit comments

Comments
 (0)