дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-09 19:25:54 +02:00
fix(editor): don't autosave while focus is in a popup over the editor
Opening a popup (intentions, completion) moved focus out of the editor and autosaved it. The save cleanup could change the text, such as trailing spaces on another line, so the quick fix the popup listed no longer matched and the first attempt to apply it failed. While focus is in a popup the editor is not saved; it is saved when focus moves on from the popup to anything but the editor.
Цей коміт міститься в:
1 джерело
0ecbc6b35d
коміт
30b0549196
2 files changed
+64
-1
No files matched your search
@@ -588,7 +588,21 @@ export class EditorController implements SlotHost {
|
||||
|
||||
onBlur(slot: EditorSlot) {
|
||||
setContext("editorTextFocus", false);
|
||||
if (this.autoSave()) void slot.model.save("auto").catch(() => {});
|
||||
if (!this.autoSave()) return;
|
||||
const save = () => void slot.model.save("auto").catch(() => {});
|
||||
if (typeof document === "undefined") return save();
|
||||
// A popup (intentions, completion, …) belongs to the editor: saving under it would change
|
||||
// the text (save cleanup) its items were computed for. Save once focus leaves it elsewhere.
|
||||
setTimeout(() => {
|
||||
if (slot.view?.hasFocus) return;
|
||||
if (!inPopup(document.activeElement)) return save();
|
||||
const onFocusIn = (e: FocusEvent) => {
|
||||
if (inPopup(e.target)) return;
|
||||
document.removeEventListener("focusin", onFocusIn);
|
||||
if (!slot.view?.hasFocus) save();
|
||||
};
|
||||
document.addEventListener("focusin", onFocusIn);
|
||||
});
|
||||
}
|
||||
|
||||
onSelection(slot: EditorSlot, navigatedFrom?: { line: number; col: number }) {
|
||||
@@ -1892,3 +1906,7 @@ function revealLabel(): string {
|
||||
const os = usePlatform.getState().os;
|
||||
return os === "macos" ? "Finder" : os === "windows" ? "Explorer" : "Files";
|
||||
}
|
||||
|
||||
function inPopup(target: EventTarget | null): boolean {
|
||||
return target instanceof Element && !!target.closest("[data-popup]");
|
||||
}
|
||||
Reference in new issue
Заблокувати користувача