mirror of
https://github.com/microsoft/vscode.git
synced 2026-05-08 09:08:48 +01:00
Tab accepts when in accept flow and and suggestion is visible even when curosr not at suggestion (#248918)
* Tab should always accept when in accept flow * only one tab to accept when inside viewport when it appears
This commit is contained in:
committed by
GitHub
parent
05e60f6e16
commit
e9e3e7a380
@@ -412,6 +412,28 @@ export class InlineCompletionsModel extends Disposable {
|
|||||||
}
|
}
|
||||||
return v?.primaryGhostText;
|
return v?.primaryGhostText;
|
||||||
});
|
});
|
||||||
|
|
||||||
|
this._jumpedToId = observableValue<undefined | string>(this, undefined);
|
||||||
|
this._inAcceptFlow = observableValue(this, false);
|
||||||
|
this.inAcceptFlow = this._inAcceptFlow;
|
||||||
|
|
||||||
|
// When the suggestion appeared, was it inside the view port or not
|
||||||
|
const appearedInsideViewport = derived<boolean>(this, reader => {
|
||||||
|
const state = this.state.read(reader);
|
||||||
|
if (!state || !state.inlineCompletion) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const targetRange = state.inlineCompletion.targetRange;
|
||||||
|
const visibleRanges = this._editorObs.editor.getVisibleRanges();
|
||||||
|
if (visibleRanges.length < 1) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
|
const viewportRange = new Range(visibleRanges[0].startLineNumber, visibleRanges[0].startColumn, visibleRanges[visibleRanges.length - 1].endLineNumber, visibleRanges[visibleRanges.length - 1].endColumn);
|
||||||
|
return viewportRange.containsRange(targetRange);
|
||||||
|
});
|
||||||
|
|
||||||
this.showCollapsed = derived<boolean>(this, reader => {
|
this.showCollapsed = derived<boolean>(this, reader => {
|
||||||
const state = this.state.read(reader);
|
const state = this.state.read(reader);
|
||||||
if (!state || state.kind !== 'inlineEdit') {
|
if (!state || state.kind !== 'inlineEdit') {
|
||||||
@@ -466,6 +488,10 @@ export class InlineCompletionsModel extends Disposable {
|
|||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
if (this._inAcceptFlow.read(reader) && appearedInsideViewport.read(reader)) {
|
||||||
|
return false;
|
||||||
|
}
|
||||||
|
|
||||||
return !s.cursorAtInlineEdit.read(reader);
|
return !s.cursorAtInlineEdit.read(reader);
|
||||||
});
|
});
|
||||||
this.tabShouldAcceptInlineEdit = derived(this, reader => {
|
this.tabShouldAcceptInlineEdit = derived(this, reader => {
|
||||||
@@ -476,6 +502,9 @@ export class InlineCompletionsModel extends Disposable {
|
|||||||
if (this.showCollapsed.read(reader)) {
|
if (this.showCollapsed.read(reader)) {
|
||||||
return false;
|
return false;
|
||||||
}
|
}
|
||||||
|
if (this._inAcceptFlow.read(reader) && appearedInsideViewport.read(reader)) {
|
||||||
|
return true;
|
||||||
|
}
|
||||||
if (s.inlineCompletion.targetRange.startLineNumber === this._editorObs.cursorLineNumber.read(reader)) {
|
if (s.inlineCompletion.targetRange.startLineNumber === this._editorObs.cursorLineNumber.read(reader)) {
|
||||||
return true;
|
return true;
|
||||||
}
|
}
|
||||||
@@ -488,9 +517,6 @@ export class InlineCompletionsModel extends Disposable {
|
|||||||
|
|
||||||
return s.cursorAtInlineEdit.read(reader);
|
return s.cursorAtInlineEdit.read(reader);
|
||||||
});
|
});
|
||||||
this._jumpedToId = observableValue<undefined | string>(this, undefined);
|
|
||||||
this._inAcceptFlow = observableValue(this, false);
|
|
||||||
this.inAcceptFlow = this._inAcceptFlow;
|
|
||||||
|
|
||||||
this._register(recomputeInitiallyAndOnChange(this._fetchInlineCompletionsPromise));
|
this._register(recomputeInitiallyAndOnChange(this._fetchInlineCompletionsPromise));
|
||||||
|
|
||||||
|
|||||||
Reference in New Issue
Block a user