stop logging when we move away, clear timeout while svg is alive.
This commit is contained in:
parent
4fe21ede2e
commit
24e55cbd49
1 changed files with 22 additions and 0 deletions
|
|
@ -90,6 +90,9 @@ export class NextEditWindowManager {
|
|||
|
||||
// Current active decoration
|
||||
private currentDecoration: vscode.TextEditorDecorationType | null = null;
|
||||
// A short-lived checker to determine if the cursor moved because of us accepting the next edit, or not.
|
||||
// Distinguishing the two is necessary to determine if we should log it as an accepted or rejected.
|
||||
private accepted: boolean = false;
|
||||
// Track which editor has the active decoration
|
||||
private activeEditor: vscode.TextEditor | null = null;
|
||||
// Store the current tooltip text for accepting
|
||||
|
|
@ -330,6 +333,7 @@ export class NextEditWindowManager {
|
|||
if (!this.activeEditor || !this.currentTooltipText) {
|
||||
return;
|
||||
}
|
||||
this.accepted = true;
|
||||
|
||||
const editor = this.activeEditor;
|
||||
const text = this.currentTooltipText;
|
||||
|
|
@ -396,6 +400,9 @@ export class NextEditWindowManager {
|
|||
this.loggingService,
|
||||
);
|
||||
this.mostRecentCompletionId = null;
|
||||
|
||||
// Reset to false for future logging.
|
||||
this.accepted = false;
|
||||
}
|
||||
|
||||
/**
|
||||
|
|
@ -459,6 +466,10 @@ export class NextEditWindowManager {
|
|||
this.activeEditor &&
|
||||
!vscode.window.visibleTextEditors.includes(this.activeEditor)
|
||||
) {
|
||||
if (this.mostRecentCompletionId)
|
||||
this.loggingService.cancelRejectionTimeout(
|
||||
this.mostRecentCompletionId,
|
||||
);
|
||||
await this.hideAllNextEditWindows();
|
||||
}
|
||||
});
|
||||
|
|
@ -467,6 +478,11 @@ export class NextEditWindowManager {
|
|||
vscode.window.onDidChangeTextEditorSelection(async (e) => {
|
||||
// If the selection changed in our active editor, hide the tooltip.
|
||||
if (this.activeEditor && e.textEditor === this.activeEditor) {
|
||||
// If the cursor moved because of something other than accepting next edit, stop logging it.
|
||||
if (!this.accepted && this.mostRecentCompletionId)
|
||||
this.loggingService.cancelRejectionTimeout(
|
||||
this.mostRecentCompletionId,
|
||||
);
|
||||
await this.hideAllNextEditWindows();
|
||||
}
|
||||
});
|
||||
|
|
@ -719,6 +735,12 @@ export class NextEditWindowManager {
|
|||
hoverMessage: [this.buildHideTooltipHoverMsg()],
|
||||
},
|
||||
]);
|
||||
|
||||
// Clear the timeout while SVG is on the editor.
|
||||
if (this.currentDecoration && this.mostRecentCompletionId)
|
||||
this.loggingService.cancelRejectionTimeoutButKeepCompletionId(
|
||||
this.mostRecentCompletionId,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Reference in a new issue