M1.13: watch open buffers' folders, bufferFocused, truncated tree row
- The parent directory of every open buffer is pinned in the project
watcher (workspace::sync_buffer_dirs after every command): it counts
against the cap but is never evicted while a buffer in it is open, so
reloads and fileChangedOnDisk arrive for never-expanded folders.
- file.open on an already-open buffer emits the new bufferFocused {id};
the editor activates that tab and it outranks pending adoptions.
- The project tree shows a "Listing truncated" note row
(project.tree.truncated) after a partly listed directory.
- Tests: engine (pinning, eviction, focus), control channel
(bufferFocused), Vitest (tab switch, race, truncated row).
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
7b7273a947
commit
8a71f7bd08
19 changed files with 312 additions and 30 deletions
|
|
@ -399,6 +399,47 @@ describe("EditorArea", () => {
|
|||
expect(area.find("[aria-selected=true]").text()).toBe("b.txt");
|
||||
});
|
||||
|
||||
it("switches to an open tab when the engine reports bufferFocused", async () => {
|
||||
const area = await mountArea();
|
||||
const editor = useEditorStore(pinia);
|
||||
await editor.openFile("a.php");
|
||||
await editor.openFile("b.txt");
|
||||
await flushPromises();
|
||||
expect(editor.activeId).toBe(2);
|
||||
emitEditorEvent({ kind: "bufferFocused", id: 1 });
|
||||
await flushPromises();
|
||||
expect(editor.activeId).toBe(1);
|
||||
expect(area.find("[aria-selected=true]").text()).toBe("a.php");
|
||||
emitEditorEvent({ kind: "bufferFocused", id: 99 });
|
||||
expect(editor.activeId).toBe(1);
|
||||
});
|
||||
|
||||
it("lets bufferFocused outrank an adoption that is still fetching", async () => {
|
||||
await mountArea();
|
||||
const editor = useEditorStore(pinia);
|
||||
await editor.openFile("a.php");
|
||||
await flushPromises();
|
||||
await execute("file.open", { path: "b.txt" });
|
||||
let release: () => void = () => undefined;
|
||||
const fallback = invoke.getMockImplementation();
|
||||
invoke.mockImplementation((cmd: string, args?: { command: string; params: Record<string, unknown> }) => {
|
||||
if (args?.command === "buffer.get" && args.params.id === 2) {
|
||||
return new Promise((resolve) => {
|
||||
release = () => {
|
||||
resolve(describeBuffer(2));
|
||||
};
|
||||
});
|
||||
}
|
||||
return fallback?.(cmd, args) as Promise<unknown>;
|
||||
});
|
||||
emitEditorEvent({ kind: "bufferOpened", id: 2, path: "b.txt" });
|
||||
emitEditorEvent({ kind: "bufferFocused", id: 1 });
|
||||
release();
|
||||
await flushPromises();
|
||||
expect(editor.tabs.map((t) => t.path).sort()).toEqual(["a.php", "b.txt"]);
|
||||
expect(editor.activeId).toBe(1);
|
||||
});
|
||||
|
||||
it("shows a notice when a dirty file changes on disk, and an open error", async () => {
|
||||
const area = await mountArea();
|
||||
const editor = useEditorStore(pinia);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue