M2.7: Structure tool window and syntax.outline
Engine: every open PHP buffer keeps a tree-sitter tree, reparsed
incrementally on a worker thread off the engine lock (200 ms debounce,
edit batches recorded by buffer.edit, full parse when the chain breaks).
syntax.outline {id} returns {items, truncated, version}; outlineChanged
{id} at most every 200 ms per buffer. Replaced trees and outlines are
freed on the worker.
UI: left stripe with Project | Structure in MainLayout, the Structure
tool window (WAI-ARIA tree, Lucide kind icons, signatures, jumps via
editor.reveal), view.toggleStructure on Mod+2.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
73819df926
commit
c68932c39c
27 changed files with 2596 additions and 28 deletions
|
|
@ -1,26 +1,34 @@
|
|||
<script setup lang="ts">
|
||||
/**
|
||||
* Layout of the main window: the Project tool window on the left, the
|
||||
* editor area in the middle, the bottom panel under both (M2.4) and the
|
||||
* status bar along the bottom.
|
||||
* Layout of the main window: the left tool-window stripe, the left tool
|
||||
* window, the editor area in the middle, the bottom panel under both
|
||||
* (M2.4) and the status bar along the bottom.
|
||||
*
|
||||
* The editor area is a slot so the editor (M1.6) can replace the
|
||||
* placeholder without touching the layout. The layout supplies the UI
|
||||
* command `view.toggleProjectTree` (`Mod+1`), which shows or hides the
|
||||
* Project tool window.
|
||||
* placeholder without touching the layout.
|
||||
*
|
||||
* The left stripe (M2.7) is a vertical tab list with Project and
|
||||
* Structure. The left tool window shows one of them; clicking the shown
|
||||
* one's tab hides the window, clicking the other switches to it. Both stay
|
||||
* mounted while the window is open, so switching keeps their state. The
|
||||
* layout supplies the UI commands `view.toggleProjectTree` (`Mod+1`) and
|
||||
* `view.toggleStructure` (`Mod+2`): each shows its tool window, or hides
|
||||
* the left window when that tool window is already shown.
|
||||
*
|
||||
* The bottom panel ({@link BottomPanel}) holds the Find tool window. It
|
||||
* appears with the UI command `find.open` (`Mod+Alt+F`, supplied here so it
|
||||
* works before the panel exists), collapses to its header and closes from
|
||||
* its header; the Find store keeps the results while it is closed.
|
||||
*/
|
||||
import { onBeforeUnmount, onMounted, ref } from "vue";
|
||||
import { FolderTree, ListTree } from "@lucide/vue";
|
||||
import { computed, onBeforeUnmount, onMounted, ref } from "vue";
|
||||
import { useCommandsStore } from "../../commands/store";
|
||||
import { t } from "../../i18n";
|
||||
import { useFindStore } from "../../stores/find";
|
||||
import FindToolWindow from "../find/FindToolWindow.vue";
|
||||
import ProjectToolWindow from "../project/ProjectToolWindow.vue";
|
||||
import StatusBar from "../StatusBar.vue";
|
||||
import StructureToolWindow from "../structure/StructureToolWindow.vue";
|
||||
import BottomPanel from "./BottomPanel.vue";
|
||||
import ToolWindow from "./ToolWindow.vue";
|
||||
|
||||
|
|
@ -31,6 +39,33 @@ const leftOpen = ref(true);
|
|||
/** Height of the bottom panel's content in CSS pixels. */
|
||||
const bottomHeight = ref(240);
|
||||
|
||||
/** Tool windows of the left side. */
|
||||
type LeftTool = "project" | "structure";
|
||||
/** The left tool window shown while {@link leftOpen} is set. */
|
||||
const leftTool = ref<LeftTool>("project");
|
||||
/** Stripe tabs in display order: id, title and icon. */
|
||||
const leftTools = computed(() => [
|
||||
{ id: "project" as const, title: t("project.toolWindow.title"), icon: FolderTree },
|
||||
{ id: "structure" as const, title: t("structure.toolWindow.title"), icon: ListTree },
|
||||
]);
|
||||
/** Title of the shown left tool window. */
|
||||
const leftTitle = computed(() => leftTools.value.find((tool) => tool.id === leftTool.value)?.title ?? "");
|
||||
|
||||
/**
|
||||
* Shows a left tool window, or hides the left window when it is already
|
||||
* shown.
|
||||
*
|
||||
* @param tool - the tool window.
|
||||
*/
|
||||
function toggleLeft(tool: LeftTool): void {
|
||||
if (leftOpen.value && leftTool.value === tool) {
|
||||
leftOpen.value = false;
|
||||
return;
|
||||
}
|
||||
leftTool.value = tool;
|
||||
leftOpen.value = true;
|
||||
}
|
||||
|
||||
const commands = useCommandsStore();
|
||||
const find = useFindStore();
|
||||
|
||||
|
|
@ -42,10 +77,15 @@ onMounted(() => {
|
|||
withdraw = [
|
||||
commands.provide("view.toggleProjectTree", {
|
||||
run: () => {
|
||||
leftOpen.value = !leftOpen.value;
|
||||
toggleLeft("project");
|
||||
},
|
||||
}),
|
||||
commands.provide("find.open", { run: (params) => find.open(params) }),
|
||||
commands.provide("view.toggleStructure", {
|
||||
run: () => {
|
||||
toggleLeft("structure");
|
||||
},
|
||||
}),
|
||||
];
|
||||
});
|
||||
|
||||
|
|
@ -61,12 +101,40 @@ onBeforeUnmount(() => {
|
|||
<template>
|
||||
<div class="main-layout">
|
||||
<div class="main-layout__row">
|
||||
<nav
|
||||
class="main-layout__stripe"
|
||||
role="tablist"
|
||||
aria-orientation="vertical"
|
||||
:aria-label="t('common.toolWindow.stripe')"
|
||||
data-test="left-stripe"
|
||||
>
|
||||
<button
|
||||
v-for="tool in leftTools"
|
||||
:key="tool.id"
|
||||
type="button"
|
||||
role="tab"
|
||||
class="main-layout__stripe-button"
|
||||
:class="{ 'main-layout__stripe-button--active': leftOpen && leftTool === tool.id }"
|
||||
:aria-selected="leftOpen && leftTool === tool.id"
|
||||
:title="tool.title"
|
||||
:aria-label="tool.title"
|
||||
:data-test="`stripe-${tool.id}`"
|
||||
@click="toggleLeft(tool.id)"
|
||||
>
|
||||
<component
|
||||
:is="tool.icon"
|
||||
:size="18"
|
||||
/>
|
||||
</button>
|
||||
</nav>
|
||||
<ToolWindow
|
||||
v-if="leftOpen"
|
||||
v-model:width="leftWidth"
|
||||
v-model:open="leftOpen"
|
||||
:title="t('project.toolWindow.title')"
|
||||
:title="leftTitle"
|
||||
>
|
||||
<ProjectToolWindow />
|
||||
<ProjectToolWindow v-show="leftTool === 'project'" />
|
||||
<StructureToolWindow v-show="leftTool === 'structure'" />
|
||||
</ToolWindow>
|
||||
<main
|
||||
class="main-layout__editor"
|
||||
|
|
@ -101,6 +169,43 @@ onBeforeUnmount(() => {
|
|||
min-height: 0;
|
||||
}
|
||||
|
||||
.main-layout__stripe {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
align-items: center;
|
||||
gap: var(--lt-space-xs, 2px);
|
||||
flex: none;
|
||||
padding: var(--lt-space-s, 4px) var(--lt-space-xs, 2px);
|
||||
background: var(--lt-bg);
|
||||
border-right: 1px solid var(--lt-border);
|
||||
}
|
||||
|
||||
.main-layout__stripe-button {
|
||||
display: inline-flex;
|
||||
align-items: center;
|
||||
justify-content: center;
|
||||
padding: var(--lt-space-xs, 2px);
|
||||
color: var(--lt-fg-muted);
|
||||
background: transparent;
|
||||
border: none;
|
||||
border-radius: var(--lt-radius, 4px);
|
||||
cursor: pointer;
|
||||
}
|
||||
|
||||
.main-layout__stripe-button:hover {
|
||||
color: var(--lt-fg);
|
||||
background: color-mix(in srgb, var(--lt-fg) 8%, transparent);
|
||||
}
|
||||
|
||||
.main-layout__stripe-button--active {
|
||||
color: var(--lt-accent);
|
||||
background: color-mix(in srgb, var(--lt-accent) 18%, transparent);
|
||||
}
|
||||
|
||||
.main-layout__stripe-button:focus-visible {
|
||||
outline: 2px solid var(--lt-accent);
|
||||
}
|
||||
|
||||
.main-layout__editor {
|
||||
flex: 1;
|
||||
min-width: 0;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue