Skip to content

Commit aefadd7

Browse files
committed
Revert "Fixes #140708 by introducing Ctrl+Right/Left keybindings to accept/undo parts of inline completions. (#171251)"
This reverts commit 140004f.
1 parent 58f0d46 commit aefadd7

File tree

1 file changed

+2
-27
lines changed

1 file changed

+2
-27
lines changed

src/vs/editor/contrib/inlineCompletions/browser/ghostTextController.ts

Lines changed: 2 additions & 27 deletions
Original file line numberDiff line numberDiff line change
@@ -18,16 +18,11 @@ import { GhostTextWidget } from 'vs/editor/contrib/inlineCompletions/browser/gho
1818
import * as nls from 'vs/nls';
1919
import { ContextKeyExpr, IContextKeyService, RawContextKey } from 'vs/platform/contextkey/common/contextkey';
2020
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
21-
import { KeybindingsRegistry } from 'vs/platform/keybinding/common/keybindingsRegistry';
2221

2322
export class GhostTextController extends Disposable {
2423
public static readonly inlineSuggestionVisible = new RawContextKey<boolean>('inlineSuggestionVisible', false, nls.localize('inlineSuggestionVisible', "Whether an inline suggestion is visible"));
2524
public static readonly inlineSuggestionHasIndentation = new RawContextKey<boolean>('inlineSuggestionHasIndentation', false, nls.localize('inlineSuggestionHasIndentation', "Whether the inline suggestion starts with whitespace"));
2625
public static readonly inlineSuggestionHasIndentationLessThanTabSize = new RawContextKey<boolean>('inlineSuggestionHasIndentationLessThanTabSize', true, nls.localize('inlineSuggestionHasIndentationLessThanTabSize', "Whether the inline suggestion starts with whitespace that is less than what would be inserted by tab"));
27-
/**
28-
* Enables to use Ctrl+Left to undo fully (partially) accepted inline completions (the completion is no longer visible then).
29-
*/
30-
public static readonly inlineSuggestionJustCommitted = new RawContextKey<boolean>('inlineSuggestionJustCommitted', false, nls.localize('inlineSuggestionJustCommitted', "Whether an inline suggestion just got committed"));
3126

3227
static ID = 'editor.contrib.ghostTextController';
3328

@@ -96,12 +91,10 @@ export class GhostTextController extends Disposable {
9691

9792
public commitPartially(): void {
9893
this.activeModel?.commitInlineCompletionPartially();
99-
this.activeController?.value?.contextKeys.inlineSuggestionJustCommitted.set(true);
10094
}
10195

10296
public commit(): void {
10397
this.activeModel?.commitInlineCompletion();
104-
this.activeController?.value?.contextKeys.inlineSuggestionJustCommitted.set(true);
10598
}
10699

107100
public hide(): void {
@@ -126,7 +119,6 @@ class GhostTextContextKeys {
126119
public readonly inlineCompletionVisible = GhostTextController.inlineSuggestionVisible.bindTo(this.contextKeyService);
127120
public readonly inlineCompletionSuggestsIndentation = GhostTextController.inlineSuggestionHasIndentation.bindTo(this.contextKeyService);
128121
public readonly inlineCompletionSuggestsIndentationLessThanTabSize = GhostTextController.inlineSuggestionHasIndentationLessThanTabSize.bindTo(this.contextKeyService);
129-
public readonly inlineSuggestionJustCommitted = GhostTextController.inlineSuggestionJustCommitted.bindTo(this.contextKeyService);
130122

131123
constructor(private readonly contextKeyService: IContextKeyService) {
132124
}
@@ -137,7 +129,7 @@ class GhostTextContextKeys {
137129
* Must be disposed as soon as the model detaches from the editor.
138130
*/
139131
export class ActiveGhostTextController extends Disposable {
140-
public readonly contextKeys = new GhostTextContextKeys(this.contextKeyService);
132+
private readonly contextKeys = new GhostTextContextKeys(this.contextKeyService);
141133
public readonly model = this._register(this.instantiationService.createInstance(GhostTextModel, this.editor));
142134
public readonly widget = this._register(this.instantiationService.createInstance(GhostTextWidget, this.editor, this.model));
143135

@@ -157,12 +149,6 @@ export class ActiveGhostTextController extends Disposable {
157149
this._register(this.model.onDidChange(() => {
158150
this.updateContextKeys();
159151
}));
160-
this._register(this.editor.onDidChangeModelContent(() => {
161-
this.contextKeys.inlineSuggestionJustCommitted.reset();
162-
}));
163-
this._register(this.editor.onDidChangeCursorPosition(() => {
164-
this.contextKeys.inlineSuggestionJustCommitted.reset();
165-
}));
166152
this.updateContextKeys();
167153
}
168154

@@ -272,11 +258,7 @@ export class AcceptNextWordOfInlineCompletion extends EditorAction {
272258
id: 'editor.action.inlineSuggest.acceptNextWord',
273259
label: nls.localize('action.inlineSuggest.acceptNextWord', "Accept Next Word Of Inline Suggestion"),
274260
alias: 'Accept Next Word Of Inline Suggestion',
275-
precondition: ContextKeyExpr.and(EditorContextKeys.writable, GhostTextController.inlineSuggestionVisible),
276-
kbOpts: {
277-
weight: 1000,
278-
primary: KeyMod.CtrlCmd | KeyCode.RightArrow,
279-
}
261+
precondition: EditorContextKeys.writable
280262
});
281263
}
282264

@@ -287,10 +269,3 @@ export class AcceptNextWordOfInlineCompletion extends EditorAction {
287269
}
288270
}
289271
}
290-
291-
KeybindingsRegistry.registerKeybindingRule({
292-
id: 'undo',
293-
weight: 1000,
294-
primary: KeyMod.CtrlCmd | KeyCode.LeftArrow,
295-
when: ContextKeyExpr.and(EditorContextKeys.writable, ContextKeyExpr.or(GhostTextController.inlineSuggestionVisible, GhostTextController.inlineSuggestionJustCommitted)),
296-
});

0 commit comments

Comments
 (0)