дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 18:17:15 +02:00
fix(plugins): flush project-tree-expanded immediately (#8347)
Plugins received project-tree-expanded only with the 500 ms workbench event batch, so notes they add to a folder's files appeared about half a second after the folder opened. The event, and anything already queued before it, is now posted at once. Co-authored-by: NikoHXX <[email protected]>
Цей коміт міститься в:
1 джерело
54149cbec5
коміт
8733a53b8b
2 files changed
+35
-1
No files matched your search
@@ -7,7 +7,8 @@ import { commands } from "@/platform/ipc";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { createMemoryPluginsBackend, setPluginsBackend, tauriPluginsBackend } from "../backend";
|
||||
import { providePluginEditorContext } from "../editorContext";
|
||||
import { startRuntimeUi } from "../runtimeUi";
|
||||
import { refreshEventKinds, startRuntimeUi } from "../runtimeUi";
|
||||
import { notifyProjectViewExpanded } from "@/workbench/contributions";
|
||||
|
||||
const project: ProjectInfo = { root: "/work", name: "work", trusted: true, isGit: false, settings: {} };
|
||||
let received: WorkbenchEvent[];
|
||||
@@ -68,6 +69,28 @@ describe("runtime UI caret event lifetime", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("project tree expansion events", () => {
|
||||
it("are posted with the folder at once, together with the events already queued", async () => {
|
||||
setPluginsBackend({
|
||||
...createMemoryPluginsBackend(),
|
||||
eventKinds: async () => ["file-saved", "project-tree-expanded"],
|
||||
postEvents: async (events) => {
|
||||
received.push(...events);
|
||||
},
|
||||
});
|
||||
refreshEventKinds();
|
||||
await vi.advanceTimersByTimeAsync(0);
|
||||
_emitEditorEvent({ type: "docSaved", doc: 1, path: "/work/a.ts" });
|
||||
notifyProjectViewExpanded(["/work/src"]);
|
||||
expect(received).toEqual([
|
||||
{ kind: "fileSaved", value: "/work/a.ts" },
|
||||
{ kind: "projectTreeExpanded", value: ["/work/src"] },
|
||||
]);
|
||||
await vi.advanceTimersByTimeAsync(1000);
|
||||
expect(received).toHaveLength(2);
|
||||
});
|
||||
});
|
||||
|
||||
const transitions = [
|
||||
{
|
||||
name: "closing the active document",
|
||||
|
||||
@@ -472,6 +472,17 @@ function post(event: WorkbenchEvent) {
|
||||
const queued = queue.findIndex((queued) => queued.kind === "caretMoved" && queued.value.path === event.value.path);
|
||||
if (queued >= 0) queue.splice(queued, 1);
|
||||
}
|
||||
// Project-tree expand notes must appear with the folder, not after the 500ms
|
||||
// workbench batch — flush this event (and anything already queued) immediately.
|
||||
if (event.kind === "projectTreeExpanded") {
|
||||
queue.push(event);
|
||||
if (postTimer) {
|
||||
clearTimeout(postTimer);
|
||||
postTimer = null;
|
||||
}
|
||||
flush();
|
||||
return;
|
||||
}
|
||||
queue.push(event);
|
||||
const delay = event.kind === "caretMoved" ? CARET_FLUSH_MS : POST_INTERVAL_MS;
|
||||
const due = Date.now() + delay;
|
||||
|
||||
Reference in new issue
Заблокувати користувача