дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-16 22:55:42 +02:00
Порівняти коміти
1
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
0a03615988 |
No files matched your search
@@ -87,7 +87,7 @@ export function activate(): () => void {
|
||||
registerOverlay({ id: "deployment.dialogs", component: DeploymentDialogs }),
|
||||
registerMenuGroup({
|
||||
id: "deployment",
|
||||
menus: ["projectView", "editor", "editorTab"],
|
||||
menus: ["projectView", "editor", "editorTab", "changes"],
|
||||
order: 60,
|
||||
items: (_menu, { paths }) => deploymentMenu(paths),
|
||||
prepare: async (_menu, { paths }) => {
|
||||
|
||||
@@ -44,7 +44,13 @@ import {
|
||||
type TreeHandle,
|
||||
T,
|
||||
} from "@/ui";
|
||||
import { editorService, maybeEditorService, type EditorInput, useMenuSlotItems } from "@/workbench/contributions";
|
||||
import {
|
||||
editorService,
|
||||
maybeEditorService,
|
||||
menuGroupItems,
|
||||
type EditorInput,
|
||||
useMenuSlotItems,
|
||||
} from "@/workbench/contributions";
|
||||
import { evaluateWhen, useContextKeys } from "@/platform/context";
|
||||
import { useToolWindowLayout } from "@/workbench/toolwindows/store";
|
||||
import {
|
||||
@@ -293,9 +299,11 @@ export function listMenu(id: string, active: boolean, files: readonly FileStatus
|
||||
|
||||
/** Paths Delete… applies to: only when every selected file is unversioned (versioned ones are rolled back). */
|
||||
/** The selected files that still exist in the working tree (Delete… removes them from disk). */
|
||||
/** Whether the change leaves the file in the working tree. */
|
||||
const onDisk = (f: FileStatus) => f.unstaged !== "deleted" && !(f.staged === "deleted" && !f.unstaged);
|
||||
|
||||
export function deletableFiles(nodes: ChangeNode[]): string[] {
|
||||
const files = filesOf(nodes);
|
||||
const onDisk = (f: FileStatus) => f.unstaged !== "deleted" && !(f.staged === "deleted" && !f.unstaged);
|
||||
return files.length && files.every(onDisk) ? files.map((f) => f.path) : [];
|
||||
}
|
||||
|
||||
@@ -428,6 +436,10 @@ export function nodeMenu(
|
||||
{ kind: "action", action: "vcs.localHistory", arg: first?.path },
|
||||
{ kind: "action", action: "vcs.annotate", arg: first?.path },
|
||||
{ kind: "separator" },
|
||||
// Other features' groups (Deployment) for the files that exist.
|
||||
...menuGroupItems("changes", {
|
||||
paths: files.filter(onDisk).map((f) => stripSlash(f.path)),
|
||||
}),
|
||||
{ label: "Copy Path", icon: "copy", run: () => copyChangePaths(nodes, "absolute") },
|
||||
{ label: "Copy File Name", icon: "copy", run: () => copyChangePaths(nodes, "name") },
|
||||
);
|
||||
|
||||
@@ -0,0 +1,29 @@
|
||||
import { afterEach, expect, it, vi } from "vitest";
|
||||
import type { FileStatus } from "@/bindings";
|
||||
import type { MenuItem } from "@/ui";
|
||||
import { registerMenuGroup } from "@/workbench/contributions";
|
||||
import type { ChangeNode } from "../changes";
|
||||
|
||||
const { nodeMenu } = await import("../CommitView");
|
||||
|
||||
const file = (rel: string, unstaged: FileStatus["unstaged"], staged: FileStatus["staged"] = null): ChangeNode => {
|
||||
const f: FileStatus = { path: `/p/${rel}`, relPath: rel, staged, unstaged, renamedFrom: null };
|
||||
return { key: f.path, type: "file", label: rel, group: "changes", files: [f], path: f.path };
|
||||
};
|
||||
|
||||
let dispose: () => void = () => {};
|
||||
afterEach(() => dispose());
|
||||
|
||||
it("adds other features' groups for the changed files still on disk", () => {
|
||||
const items = vi.fn((_menu: string, { paths }: { paths: string[] }): MenuItem[] =>
|
||||
paths.length ? [{ id: "deployment", label: "Deployment", submenu: [] }] : [],
|
||||
);
|
||||
dispose = registerMenuGroup({ id: "deployment", menus: ["changes"], items });
|
||||
const labels = (menu: MenuItem[]) => menu.flatMap((i) => (i.kind !== "separator" && "label" in i ? [i.label] : []));
|
||||
|
||||
const menu = nodeMenu([file("a.txt", "modified"), file("gone.txt", "deleted"), file("new.txt", "untracked")], ["/p"]);
|
||||
expect(items).toHaveBeenLastCalledWith("changes", { paths: ["/p/a.txt", "/p/new.txt"] });
|
||||
expect(labels(menu)).toContain("Deployment");
|
||||
|
||||
expect(labels(nodeMenu([file("gone.txt", "deleted")], ["/p"]))).not.toContain("Deployment");
|
||||
});
|
||||
@@ -1273,6 +1273,7 @@ export type ContextMenuId =
|
||||
| "editor"
|
||||
| "projectView"
|
||||
| "editorTab"
|
||||
| "changes"
|
||||
| "problems"
|
||||
| "searchResults"
|
||||
| "editorGutter"
|
||||
|
||||
Reference in new issue
Заблокувати користувача