M2.4: Find tool window in a new bottom panel
- Bottom panel under editor and project tree (resizable, collapsible,
closable) for Find and later tool windows.
- Find store: search.find with options and include/exclude globs, results
streamed and sorted by file, events held until the searchId answer, a
new search cancels the running one, refused queries shown in place.
- Find tool window: toggles, counts, cancel, truncated hint, highlighted
previews, keyboard navigation, Enter or click runs editor.reveal.
- UI command find.open (Mod+Alt+F) with prefill from the selection or the
word at the cursor; find.open {query} from agents searches at once.
- 26 Vitest tests; progress docs and architecture updated.
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
This commit is contained in:
parent
864a468b34
commit
097bbd9409
16 changed files with 1923 additions and 25 deletions
239
ui/src/components/layout/BottomPanel.vue
Normal file
239
ui/src/components/layout/BottomPanel.vue
Normal file
|
|
@ -0,0 +1,239 @@
|
|||
<script setup lang="ts">
|
||||
/**
|
||||
* The bottom panel of the main window: a tool window docked under the
|
||||
* editor (Find since M2.4; later Problems, Terminal and others). A header
|
||||
* with the title, a collapse/expand button and a close button, the content
|
||||
* slot, and a splitter on the top edge to resize it.
|
||||
*
|
||||
* The splitter is dragged with the pointer or moved with Up/Down (Shift for
|
||||
* larger steps) when focused. Collapsed, only the header shows. Height and
|
||||
* expansion are view state, emitted through `v-model:height` and
|
||||
* `v-model:open`; the close button emits `close`, and the owner decides
|
||||
* what closing means.
|
||||
*/
|
||||
import { ChevronDown, ChevronUp, X } from "@lucide/vue";
|
||||
import { computed } from "vue";
|
||||
import { t } from "../../i18n";
|
||||
|
||||
/** Props of the bottom panel. */
|
||||
const props = withDefaults(
|
||||
defineProps<{
|
||||
/** Title shown in the header and as the accessible name. */
|
||||
title: string;
|
||||
/** Height of the content in CSS pixels, header excluded. */
|
||||
height?: number;
|
||||
/** Smallest height the splitter allows. */
|
||||
minHeight?: number;
|
||||
/** Largest height the splitter allows. */
|
||||
maxHeight?: number;
|
||||
/** Whether the panel is expanded (true) or collapsed to its header. */
|
||||
open?: boolean;
|
||||
}>(),
|
||||
{ height: 240, minHeight: 80, maxHeight: 900, open: true },
|
||||
);
|
||||
|
||||
/** Events of the bottom panel. */
|
||||
const emit = defineEmits<{
|
||||
/** New height after a resize. */
|
||||
"update:height": [height: number];
|
||||
/** New expansion after collapse or expand. */
|
||||
"update:open": [open: boolean];
|
||||
/** The close button was pressed. */
|
||||
close: [];
|
||||
}>();
|
||||
|
||||
/** Inline style carrying the current height. */
|
||||
const bodyStyle = computed(() => ({ height: `${String(props.height)}px` }));
|
||||
|
||||
/**
|
||||
* Emits a height clamped to the allowed range.
|
||||
*
|
||||
* @param height - the wanted height.
|
||||
*/
|
||||
function setHeight(height: number): void {
|
||||
emit("update:height", Math.round(Math.min(props.maxHeight, Math.max(props.minHeight, height))));
|
||||
}
|
||||
|
||||
/**
|
||||
* Starts a pointer drag on the splitter; dragging up makes the panel taller.
|
||||
*
|
||||
* @param event - the pointer-down event.
|
||||
*/
|
||||
function onSplitterDown(event: PointerEvent): void {
|
||||
const target = event.currentTarget;
|
||||
if (!(target instanceof HTMLElement)) {
|
||||
return;
|
||||
}
|
||||
const startY = event.clientY;
|
||||
const startHeight = props.height;
|
||||
target.setPointerCapture(event.pointerId);
|
||||
const move = (e: PointerEvent): void => {
|
||||
setHeight(startHeight - (e.clientY - startY));
|
||||
};
|
||||
const up = (e: PointerEvent): void => {
|
||||
target.releasePointerCapture(e.pointerId);
|
||||
target.removeEventListener("pointermove", move);
|
||||
target.removeEventListener("pointerup", up);
|
||||
};
|
||||
target.addEventListener("pointermove", move);
|
||||
target.addEventListener("pointerup", up);
|
||||
}
|
||||
|
||||
/**
|
||||
* Resizes with the keyboard when the splitter has focus.
|
||||
*
|
||||
* @param event - the key event.
|
||||
*/
|
||||
function onSplitterKey(event: KeyboardEvent): void {
|
||||
const step = event.shiftKey ? 48 : 12;
|
||||
if (event.key === "ArrowUp") {
|
||||
setHeight(props.height + step);
|
||||
} else if (event.key === "ArrowDown") {
|
||||
setHeight(props.height - step);
|
||||
} else {
|
||||
return;
|
||||
}
|
||||
event.preventDefault();
|
||||
}
|
||||
</script>
|
||||
|
||||
<template>
|
||||
<section
|
||||
class="bottom-panel"
|
||||
:aria-label="title"
|
||||
data-test="bottom-panel"
|
||||
>
|
||||
<div
|
||||
v-if="open"
|
||||
class="bottom-panel__splitter"
|
||||
role="separator"
|
||||
aria-orientation="horizontal"
|
||||
tabindex="0"
|
||||
:aria-valuenow="height"
|
||||
:aria-valuemin="minHeight"
|
||||
:aria-valuemax="maxHeight"
|
||||
:aria-label="t('common.toolWindow.resize', { title })"
|
||||
data-test="bottom-panel-splitter"
|
||||
@pointerdown="onSplitterDown"
|
||||
@keydown="onSplitterKey"
|
||||
/>
|
||||
<header class="bottom-panel__header">
|
||||
<span class="bottom-panel__title">{{ title }}</span>
|
||||
<span class="bottom-panel__actions">
|
||||
<button
|
||||
type="button"
|
||||
class="bottom-panel__button"
|
||||
:title="open ? t('common.toolWindow.collapse', { title }) : t('common.toolWindow.expand', { title })"
|
||||
:aria-label="open ? t('common.toolWindow.collapse', { title }) : t('common.toolWindow.expand', { title })"
|
||||
:aria-expanded="open"
|
||||
data-test="bottom-panel-toggle"
|
||||
@click="emit('update:open', !open)"
|
||||
>
|
||||
<ChevronDown
|
||||
v-if="open"
|
||||
:size="16"
|
||||
/>
|
||||
<ChevronUp
|
||||
v-else
|
||||
:size="16"
|
||||
/>
|
||||
</button>
|
||||
<button
|
||||
type="button"
|
||||
class="bottom-panel__button"
|
||||
:title="t('common.toolWindow.hide', { title })"
|
||||
:aria-label="t('common.toolWindow.hide', { title })"
|
||||
data-test="bottom-panel-close"
|
||||
@click="emit('close')"
|
||||
>
|
||||
<X :size="16" />
|
||||
</button>
|
||||
</span>
|
||||
</header>
|
||||
<div
|
||||
v-if="open"
|
||||
class="bottom-panel__body"
|
||||
:style="bodyStyle"
|
||||
>
|
||||
<slot />
|
||||
</div>
|
||||
</section>
|
||||
</template>
|
||||
|
||||
<style scoped>
|
||||
.bottom-panel {
|
||||
position: relative;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
flex: none;
|
||||
max-height: 75%;
|
||||
background: var(--lt-bg);
|
||||
border-top: 1px solid var(--lt-border);
|
||||
}
|
||||
|
||||
.bottom-panel__header {
|
||||
display: flex;
|
||||
align-items: center;
|
||||
justify-content: space-between;
|
||||
flex: none;
|
||||
height: var(--lt-header-height, 28px);
|
||||
padding: 0 var(--lt-space-s, 4px) 0 var(--lt-space-m, 8px);
|
||||
border-bottom: 1px solid var(--lt-border);
|
||||
}
|
||||
|
||||
.bottom-panel__title {
|
||||
font-weight: 600;
|
||||
overflow: hidden;
|
||||
text-overflow: ellipsis;
|
||||
white-space: nowrap;
|
||||
}
|
||||
|
||||
.bottom-panel__actions {
|
||||
display: inline-flex;
|
||||
gap: var(--lt-space-xs, 2px);
|
||||
}
|
||||
|
||||
.bottom-panel__body {
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
min-height: 0;
|
||||
flex-shrink: 1;
|
||||
}
|
||||
|
||||
.bottom-panel__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;
|
||||
}
|
||||
|
||||
.bottom-panel__button:hover {
|
||||
color: var(--lt-fg);
|
||||
background: color-mix(in srgb, var(--lt-fg) 8%, transparent);
|
||||
}
|
||||
|
||||
.bottom-panel__button:focus-visible {
|
||||
outline: 2px solid var(--lt-accent);
|
||||
}
|
||||
|
||||
.bottom-panel__splitter {
|
||||
position: absolute;
|
||||
top: -3px;
|
||||
right: 0;
|
||||
left: 0;
|
||||
height: 6px;
|
||||
cursor: row-resize;
|
||||
z-index: 1;
|
||||
}
|
||||
|
||||
.bottom-panel__splitter:hover,
|
||||
.bottom-panel__splitter:focus-visible {
|
||||
outline: none;
|
||||
background: color-mix(in srgb, var(--lt-accent) 50%, transparent);
|
||||
}
|
||||
</style>
|
||||
Loading…
Add table
Add a link
Reference in a new issue