Skip to content

Commit 0278a0e

Browse files
authored
Handle slash command deletion on keydown (microsoft#188949)
1 parent 525f0a6 commit 0278a0e

File tree

1 file changed

+4
-4
lines changed

1 file changed

+4
-4
lines changed

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

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,7 @@ export class SlashCommandContentWidget extends Disposable implements IContentWid
2323
this._domNode.classList.add('chat-slash-command-content-widget');
2424

2525
// If backspace at a slash command boundary, remove the slash command
26-
this._register(this._editor.onKeyUp((e) => this._handleKeyUp(e)));
26+
this._register(this._editor.onKeyDown((e) => this._handleKeyDown(e)));
2727
}
2828

2929
override dispose() {
@@ -50,20 +50,20 @@ export class SlashCommandContentWidget extends Disposable implements IContentWid
5050
getDomNode() { return this._domNode; }
5151
getPosition() { return { position: { lineNumber: 1, column: 1 }, preference: [ContentWidgetPositionPreference.EXACT] }; }
5252

53-
private _handleKeyUp(e: IKeyboardEvent) {
53+
private _handleKeyDown(e: IKeyboardEvent) {
5454
if (e.keyCode !== KeyCode.Backspace) {
5555
return;
5656
}
5757

5858
const firstLine = this._editor.getModel()?.getLineContent(1);
5959
const selection = this._editor.getSelection();
60-
const withSlash = `/${this._lastSlashCommandText}`;
60+
const withSlash = `/${this._lastSlashCommandText} `;
6161
if (!firstLine?.startsWith(withSlash) || !selection?.isEmpty() || selection?.startLineNumber !== 1 || selection?.startColumn !== withSlash.length + 1) {
6262
return;
6363
}
6464

6565
// Allow to undo the backspace
66-
this._editor.executeEdits('inline-chat-slash-command', [{
66+
this._editor.executeEdits('chat-slash-command', [{
6767
range: new Range(1, 1, 1, selection.startColumn),
6868
text: null
6969
}]);

0 commit comments

Comments
 (0)