feat(plugins): notes after file names in the project tree (API 1.7) (#3085)

Tree decorations could carry only a two-character badge and a tooltip. decorations.set-file-note (API 1.7) shows one line of muted text (at most 200 characters, optional tooltip) after a file or folder name in the project tree, replacing that tree set's item for the file and sharing the tree-set limits. The SDK wraps it as host::set_file_note with a mock; checked-in components rebuilt.
This commit is contained in:
l0ng-ai
2026-11-13 14:18:04 +08:00
committed by GitHub
parent 73df48db7c
commit df79c80aa8
55 changed files with 164 additions and 52 deletions
@@ -66,6 +66,19 @@ it("filters project roots and unknown styles and replaces tree badges", () => {
expect(getFileDecoration("/p/a.txt")?.badge).toBeUndefined();
});
it("shows a tree note after the name without colouring the file", () => {
const note = {
...set(),
tree: true,
items: [],
file: { style: "", badge: null, tooltip: "why", note: "entry point" },
};
setPluginDecorations("test", [note]);
expect(getFileDecoration("/p/a.txt")).toMatchObject({ suffix: [{ text: "entry point" }], tooltip: "why" });
expect(getFileDecoration("/p/a.txt")?.color).toBeUndefined();
setPluginDecorations("test", []);
});
it("selects UTF-16 ranges and reveals without changing text", () => {
handleRuntimeEvent({ type: "editorRanges", path: ctx.path, ranges: [range], reveal: false });
expect(editor.view.state.selection.main.from).toBe(2);
+4 -2
View File
@@ -32,13 +32,15 @@ function currentSets(sets: DecorationSet[]) {
function updateTree(plugin: string, sets: DecorationSet[]) {
const items = new Map<string, FileDecoration>();
for (const s of currentSets(sets))
if (s.tree && s.file && Object.hasOwn(colors, s.file.style)) {
if (s.tree && s.file && (Object.hasOwn(colors, s.file.style) || s.file.note)) {
items.set(s.path, {
color: colors[s.file.style],
color: Object.hasOwn(colors, s.file.style) ? colors[s.file.style] : undefined,
badge: s.file.badge ?? undefined,
tooltip: s.file.tooltip ?? undefined,
faded: s.file.style === "muted",
error: s.file.style === "error",
// A note: muted text after the name, like the VCS branch of a root.
suffix: s.file.note ? [{ text: s.file.note }] : undefined,
});
}
setFileDecorations(`plugin:${plugin}`, items);