Engine (`cmd/lsp_nav.rs`, on the pending outcomes of 20d1d28):
- `lsp.definition` (F12) and `lsp.references` (Shift+F12, sorted, with
line previews) return project-relative locations; locations outside
the project, such as PHAR stubs and symlink escapes, are dropped.
- `lsp.prepareRename` uses the word at the cursor when the server has
no prepareProvider.
- `lsp.rename` (F2) applies the workspace edit (`lsp_nav/edit.rs`):
1. Check everything first: inside the project, ranges fit (UTF-16,
CRLF), open buffers unchanged since the request, no file
operations, no incomplete edit.
2. Write closed files atomically through the VFS, restoring earlier
writes when a later one fails.
3. Change open buffers through `buffer.edit` (dirty, undoable).
4. Send each written file to Phpactor as didOpen/didSave/didClose
plus didChangeWatchedFiles; without this its index kept the old
names. Then the summary notification `notification.lsp.renamed`.
UI (`components/editor/nav/`):
- Mod+click goes to the definition, with a pointer cursor while Mod is
held.
- A location picker for several definitions (exclusive modal).
- A References tab in the bottom panel, grouped by file.
- An inline rename field with a use/file count (exclusive modal).
- `BufferSync.beginUndoableRemote` puts the engine's rename edit into
the editor history as one undo step per buffer.
- Catalog strings and tokens only.
Fake LSP server: `--script FILE` with scripted capabilities and
answers (additive next to M3.4's arms).
Tests:
- `crates/engine/tests/lsp_nav.rs` (fake): definition; bad positions;
references; prepareRename; a multi-file rename incl. a closed CRLF
file; refusals for outside the project, a bad range, a stale buffer,
bad names and no server.
- The ignored real-Phpactor test covers definition, references and a
rename and back across 3 files.
- Vitest `ui/tests/nav/`.
Live (Phpactor 2026.06.25.0, Windows, port 7935, tick on):
- definition 93 ms cold / 7-18 ms warm
- references ~140 ms
- prepareRename ~11 ms
- rename 28-59 ms
- index follows written files in 140 ms
- Phpactor 57 MB working set, ~1.6% of a core while ticking idle
Gate: 13 steps, 197 s, Vitest 484 + 1 skipped.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
29 lines
741 B
Vue
29 lines
741 B
Vue
<script setup lang="ts">
|
|
/**
|
|
* Mounts the navigation overlays (M3.5), the location picker and the
|
|
* inline rename field, and starts the nav store, which supplies the
|
|
* context of `lsp.definition`, `lsp.references` and `lsp.rename` and the
|
|
* Mod+click handler. The References tab lives in the bottom panel
|
|
* (`MainLayout.vue`).
|
|
*/
|
|
import { onBeforeUnmount, onMounted } from "vue";
|
|
import { activeView } from "./navExtension";
|
|
import { useNavStore } from "./nav";
|
|
import NavPicker from "./NavPicker.vue";
|
|
import RenameInput from "./RenameInput.vue";
|
|
|
|
const nav = useNavStore();
|
|
|
|
onMounted(() => {
|
|
nav.start(activeView);
|
|
});
|
|
|
|
onBeforeUnmount(() => {
|
|
nav.stop();
|
|
});
|
|
</script>
|
|
|
|
<template>
|
|
<NavPicker />
|
|
<RenameInput />
|
|
</template>
|