Announce chat slash command deletion (#188215)

* Announce chat slash command deletion

* Fix localization formatting
This commit is contained in:
Joyce Er
2023-07-19 10:13:39 -07:00
committed by GitHub
parent 37c5709c96
commit 2e615c0542
3 changed files with 10 additions and 3 deletions
@@ -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));
}
}
@@ -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);
@@ -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