stop logging when we move away, clear timeout while svg is alive.

This commit is contained in:
Jacob Kim 2025-07-03 15:57:20 -07:00
parent 4fe21ede2e
commit 24e55cbd49

View file

@ -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,
);
}
}