Порівняти коміти

...
Автор SHA1 Повідомлення Дата
l0ng-ai 0682bc5f6b feat(settings): choose PHP include paths with a folder chooser
+ under Settings › Languages & Frameworks › PHP › Include paths opens a folder
chooser and adds the picked folder; Edit and double-click still take a typed
path. Outside the desktop app + keeps adding a row to type into. Additional
stubs are stub names, so that list stays typed.

Closes #3912
2026-11-17 22:00:33 +08:00
5 змінених файлів з 61 додано та 8 видалено

No files matched your search

+37
Переглянути файл
@@ -0,0 +1,37 @@
import { beforeEach, expect, it, vi } from "vitest";
import { act, fireEvent, render, screen } from "@testing-library/react";
const { choose, tauri } = vi.hoisted(() => ({ choose: vi.fn(), tauri: { on: true } }));
vi.mock("@/platform/choosePath", () => ({ choosePath: choose }));
vi.mock("@/platform/ipc", async (original) => ({
...(await original<typeof import("@/platform/ipc")>()),
isTauri: () => tauri.on,
}));
import { GlobListEditor } from "../components/Form";
beforeEach(() => {
choose.mockReset();
tauri.on = true;
});
const browse = { directory: true, title: "Choose Include Path" };
it("adds the folder picked in the chooser and leaves the list alone when it is cancelled", async () => {
const onChange = vi.fn();
choose.mockResolvedValueOnce("/opt/platform").mockResolvedValueOnce(null);
render(<GlobListEditor value={["/a"]} onChange={onChange} browse={browse} aria-label="Include paths" />);
await act(async () => fireEvent.click(screen.getByRole("button", { name: "Add" })));
expect(choose).toHaveBeenCalledWith({ directory: true, title: "Choose Include Path" });
expect(onChange).toHaveBeenCalledWith(["/a", "/opt/platform"]);
await act(async () => fireEvent.click(screen.getByRole("button", { name: "Add" })));
expect(onChange).toHaveBeenCalledTimes(1);
expect(screen.queryByRole("textbox")).not.toBeInTheDocument();
});
it("types the path inline without a chooser", async () => {
tauri.on = false;
render(<GlobListEditor value={[]} onChange={vi.fn()} browse={browse} itemLabel="Include path" />);
await act(async () => fireEvent.click(screen.getByRole("button", { name: "Add" })));
expect(choose).not.toHaveBeenCalled();
expect(screen.getByRole("textbox", { name: "Include path" })).toBeInTheDocument();
});
+19 -6
Переглянути файл
@@ -7,6 +7,8 @@ import { useId, useRef, useState, type KeyboardEvent, type ReactNode } from "rea
import clsx from "clsx";
import { Checkbox, IconButton, Input, Select as UiSelect, type SelectOption, T } from "@/ui";
import { tx, useTx } from "@/platform/i18n";
import { choosePath } from "@/platform/choosePath";
import { isTauri } from "@/platform/ipc";
import { highlightIndices } from "../model/pages";
import { HEX_COLOR } from "../model/schema";
import { useLabelMatch, useSearchQuery, useSetting } from "./context";
@@ -303,6 +305,8 @@ export interface GlobListEditorProps {
emptyText?: string;
/** Accessible name of the inline editor. */
itemLabel?: string;
/** Entries are paths: + opens this chooser (Edit still takes typing). */
browse?: { directory: boolean; title: string };
}
/** Editable list of glob patterns (+ / − / edit toolbar, inline editing); also plain string lists. */
@@ -312,6 +316,7 @@ export function GlobListEditor({
placeholder = "**/pattern",
emptyText = "No patterns",
itemLabel = "Pattern",
browse,
...aria
}: GlobListEditorProps) {
const [selected, setSelected] = useState<number | null>(null);
@@ -340,6 +345,19 @@ export function GlobListEditor({
setEditing(null);
};
const add = async () => {
// Outside the desktop app there is no chooser: type the path instead.
if (!browse || !isTauri()) {
setEditing({ index: value.length, text: "" });
return;
}
const picked = await choosePath({ ...browse, title: tx(browse.title) });
if (!picked) return;
const next = [...new Set([...value, picked])];
onChange(next);
setSelected(next.indexOf(picked));
};
const remove = () => {
if (selected === null) return;
const next = value.filter((_, i) => i !== selected);
@@ -380,12 +398,7 @@ export function GlobListEditor({
return (
<div className={styles.globEditor}>
<div className={styles.listToolbar} role="toolbar" aria-controls={listId}>
<IconButton
icon="plus"
title="Add"
size="small"
onClick={() => setEditing({ index: value.length, text: "" })}
/>
<IconButton icon="plus" title="Add" size="small" onClick={() => void add()} />
<IconButton icon="minus" title="Remove" size="small" disabled={selected === null} onClick={remove} />
<IconButton
icon="edit"
+1
Переглянути файл
@@ -221,6 +221,7 @@ export function PhpPage() {
emptyText="No include paths"
itemLabel="Include path"
aria-label="Include paths"
browse={{ directory: true, title: "Choose Include Path" }}
/>
</Row>
<Row
+2 -1
Переглянути файл
@@ -2381,5 +2381,6 @@
"Commit Message Generation": "Commit Message Generation",
"Instructions for Generate Commit Message with Agent": "Instructions for Generate Commit Message with Agent",
"Added to the agent's prompt, e.g. a commit format, issue key prefixes or the language to write in.": "Added to the agent's prompt, e.g. a commit format, issue key prefixes or the language to write in.",
"Use Conventional Commits (feat:, fix:, …) and start with the issue key if the branch has one.": "Use Conventional Commits (feat:, fix:, …) and start with the issue key if the branch has one."
"Use Conventional Commits (feat:, fix:, …) and start with the issue key if the branch has one.": "Use Conventional Commits (feat:, fix:, …) and start with the issue key if the branch has one.",
"Choose Include Path": "Choose Include Path"
}
+2 -1
Переглянути файл
@@ -8759,5 +8759,6 @@
"Commit Message Generation": "提交信息生成",
"Instructions for Generate Commit Message with Agent": "用 Agent 生成提交信息时的要求",
"Added to the agent's prompt, e.g. a commit format, issue key prefixes or the language to write in.": "会加到 Agent 的提示词里,例如提交格式、问题编号前缀或使用的语言。",
"Use Conventional Commits (feat:, fix:, …) and start with the issue key if the branch has one.": "使用 Conventional Commits(feat:、fix: 等),分支带问题编号时以它开头。"
"Use Conventional Commits (feat:, fix:, …) and start with the issue key if the branch has one.": "使用 Conventional Commits(feat:、fix: 等),分支带问题编号时以它开头。",
"Choose Include Path": "选择包含路径"
}