дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-05 17:47:08 +02:00
Порівняти коміти
2
Коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
c08664d2d3 | ||
|
|
b4cad6ec1b |
No files matched your search
@@ -128,6 +128,11 @@ export interface FileLink extends LinkPosition {
|
||||
}
|
||||
|
||||
/** The file links on the `shown` lines (a collapsed fold hides its links), in output order. */
|
||||
/** A copy of a line the model may still append to (the open last line). */
|
||||
function copyLine(line: ConsoleLine): ConsoleLine {
|
||||
return { ...line, spans: line.spans.map((span) => ({ ...span })) };
|
||||
}
|
||||
|
||||
export function fileLinks(lines: readonly ConsoleLine[], shown: (index: number) => boolean): FileLink[] {
|
||||
const links: FileLink[] = [];
|
||||
lines.forEach((line, i) => {
|
||||
@@ -257,7 +262,12 @@ export function ConsoleView({
|
||||
}: ConsoleViewProps) {
|
||||
const scrollRef = useRef<HTMLDivElement>(null);
|
||||
const innerRef = useRef<HTMLDivElement>(null);
|
||||
const lines = model.lines;
|
||||
// Pause Output: the output so far stays on screen while the process keeps
|
||||
// writing; resuming shows everything that arrived meanwhile.
|
||||
const [paused, setPaused] = useState<readonly ConsoleLine[] | null>(null);
|
||||
const lines = paused ?? model.lines;
|
||||
const togglePaused = () =>
|
||||
setPaused((p) => (p ? null : model.lines.map((l, i, all) => (i === all.length - 1 ? copyLine(l) : l))));
|
||||
const patterns = useWorkflowSettings((s) => s.console.foldPatterns);
|
||||
const logColors = useWorkflowSettings((s) => s.console.logColors);
|
||||
const consoleRules = compileConsoleRules(useConsoleRules((s) => s.providers));
|
||||
@@ -539,7 +549,16 @@ export function ConsoleView({
|
||||
// Opens Settings › Console with the text added to the fold patterns, for OK / Cancel there.
|
||||
run: () => void executeAction("file.settings", `build.console#${foldText}`),
|
||||
},
|
||||
{ label: "Clear All", icon: "trash", disabled: !onClear, run: () => onClear?.() },
|
||||
{ label: "Pause Output", icon: "pause", checked: !!paused, run: togglePaused },
|
||||
{
|
||||
label: "Clear All",
|
||||
icon: "trash",
|
||||
disabled: !onClear,
|
||||
run: () => {
|
||||
setPaused(null);
|
||||
onClear?.();
|
||||
},
|
||||
},
|
||||
...(input
|
||||
? [{ kind: "separator" } as const, { label: "Send EOF", shortcut: "⌃D", run: () => input.onEof() }]
|
||||
: []),
|
||||
|
||||
@@ -0,0 +1,52 @@
|
||||
import { afterEach, beforeEach, expect, it, vi } from "vitest";
|
||||
import { act, fireEvent, render, within } from "@testing-library/react";
|
||||
import { useProject } from "@/platform/project";
|
||||
import { hideContextMenu, useContextMenuStore } from "@/ui";
|
||||
import { ConsoleModel } from "./console";
|
||||
import { ConsoleView } from "./ConsoleView";
|
||||
|
||||
vi.mock("@tanstack/react-virtual", () => ({
|
||||
useVirtualizer: ({ count }: { count: number }) => ({
|
||||
getTotalSize: () => count * 20,
|
||||
getVirtualItems: () => Array.from({ length: count }, (_, index) => ({ index, start: index * 20, key: index })),
|
||||
scrollToIndex: () => {},
|
||||
measureElement: () => {},
|
||||
measure: () => {},
|
||||
}),
|
||||
}));
|
||||
|
||||
beforeEach(() => useProject.setState({ settings: null }));
|
||||
afterEach(() => act(hideContextMenu));
|
||||
|
||||
function pauseItem(log: Element) {
|
||||
fireEvent.contextMenu(log);
|
||||
const items = useContextMenuStore.getState().menu?.items ?? [];
|
||||
return items.find((i) => "label" in i && i.label === "Pause Output") as
|
||||
| { checked?: boolean; run?: () => void }
|
||||
| undefined;
|
||||
}
|
||||
|
||||
it("Pause Output keeps the output on screen until it is resumed, then shows what arrived meanwhile", () => {
|
||||
const model = new ConsoleModel();
|
||||
model.append({ kind: "stdout", text: "first\nsecond " });
|
||||
const view = (version: number) => (
|
||||
<ConsoleView model={model} version={version} softWrap={false} follow={false} onFollowChange={() => {}} cwd="/" />
|
||||
);
|
||||
const { container, rerender } = render(view(1));
|
||||
const log = within(container).getByRole("log");
|
||||
expect(pauseItem(log)?.checked).toBe(false);
|
||||
act(() => pauseItem(log)!.run!());
|
||||
|
||||
// The open line and new lines keep arriving while paused, but are not shown.
|
||||
model.append({ kind: "stdout", text: "half\nthird\n" });
|
||||
rerender(view(2));
|
||||
expect(log.textContent).toContain("first");
|
||||
expect(log.textContent).toContain("second");
|
||||
expect(log.textContent).not.toContain("half");
|
||||
expect(log.textContent).not.toContain("third");
|
||||
expect(pauseItem(log)?.checked).toBe(true);
|
||||
|
||||
act(() => pauseItem(log)!.run!());
|
||||
expect(log.textContent).toContain("second half");
|
||||
expect(log.textContent).toContain("third");
|
||||
});
|
||||
@@ -6,6 +6,7 @@ const mocks = vi.hoisted(() => ({
|
||||
update: vi.fn(),
|
||||
updateCurrent: vi.fn(),
|
||||
head: vi.fn(),
|
||||
checkout: vi.fn(),
|
||||
notify: vi.fn(),
|
||||
openWorktree: vi.fn(),
|
||||
}));
|
||||
@@ -22,7 +23,7 @@ vi.mock("../ops", async (original) => ({
|
||||
vi.mock("../openWorktree", () => ({ openWorktree: mocks.openWorktree }));
|
||||
vi.mock("@/platform/ipc", async (original) => {
|
||||
const real = await original<typeof import("@/platform/ipc")>();
|
||||
return { ...real, commands: { ...real.commands, vcsBranchInfo: mocks.head } };
|
||||
return { ...real, commands: { ...real.commands, vcsBranchInfo: mocks.head, vcsCheckout: mocks.checkout } };
|
||||
});
|
||||
vi.mock("@/workbench/contributions", async (original) => ({
|
||||
...(await original<typeof import("@/workbench/contributions")>()),
|
||||
@@ -30,7 +31,7 @@ vi.mock("@/workbench/contributions", async (original) => ({
|
||||
}));
|
||||
|
||||
import { branchMenu, commonBranchMenu } from "../branchMenu";
|
||||
import { branchUpdateSummary, updateBranches } from "../branchOps";
|
||||
import { branchUpdateSummary, checkoutAndUpdate, updateBranches } from "../branchOps";
|
||||
import { getAction } from "@/platform/actions";
|
||||
import { useProject } from "@/platform/project";
|
||||
import type { Settings } from "@/bindings";
|
||||
@@ -209,3 +210,38 @@ describe("branch common to several repositories", () => {
|
||||
]);
|
||||
});
|
||||
});
|
||||
|
||||
describe("Checkout and Update", () => {
|
||||
const item = (items: ReturnType<typeof branchMenu>) =>
|
||||
items.find((i) => "label" in i && i.label === "Checkout and Update") as { disabled?: boolean } | undefined;
|
||||
|
||||
it("is offered for a local branch that is not checked out, and needs a tracked branch", () => {
|
||||
expect(item(branchMenu(branch("topic"), "main"))?.disabled).toBe(false);
|
||||
expect(item(branchMenu(branch("topic", { upstream: null }), "main"))?.disabled).toBe(true);
|
||||
expect(item(branchMenu(branch("origin/topic", { remote: true, upstream: null }), "main"))).toBeUndefined();
|
||||
expect(item(branchMenu(branch("main", { current: true }), "main"))).toBeUndefined();
|
||||
const common = { name: "feature", remote: false, current: false, favorite: false, upstream: true };
|
||||
expect(item(commonBranchMenu(common, ["/p", "/p/lib"], null))?.disabled).toBe(false);
|
||||
});
|
||||
|
||||
it("checks the branch out, then pulls it with the configured method", async () => {
|
||||
let head = "main";
|
||||
mocks.checkout.mockImplementation(async () => {
|
||||
head = "topic";
|
||||
return { status: "ok", data: { kind: "done" } };
|
||||
});
|
||||
mocks.head.mockImplementation(async () => ({ status: "ok", data: { head, upstream: `origin/${head}` } }));
|
||||
await checkoutAndUpdate(branch("topic"));
|
||||
expect(mocks.checkout).toHaveBeenCalledTimes(1);
|
||||
expect(mocks.updateCurrent).toHaveBeenCalledWith([
|
||||
{ repo: "/p", op: { op: "pull", expectedBranch: "topic", rebase: false } },
|
||||
]);
|
||||
});
|
||||
|
||||
it("updates nothing when the checkout did not happen", async () => {
|
||||
mocks.checkout.mockResolvedValue({ status: "error", error: { kind: "failed", message: "nope" } });
|
||||
await checkoutAndUpdate(branch("topic"));
|
||||
expect(mocks.updateCurrent).not.toHaveBeenCalled();
|
||||
expect(mocks.update).not.toHaveBeenCalled();
|
||||
});
|
||||
});
|
||||
@@ -5,6 +5,7 @@ import { showContextMenu, useContextMenuStore, type MenuItem } from "@/ui";
|
||||
import { isFavoriteBranch } from "./branches";
|
||||
import {
|
||||
branchRef,
|
||||
checkoutAndUpdate,
|
||||
checkoutBranch,
|
||||
checkoutDetached,
|
||||
checkoutInRepos,
|
||||
@@ -158,6 +159,15 @@ export function branchMenu(
|
||||
}
|
||||
const items: MenuItem[] = [
|
||||
{ label: "Checkout", run: run(() => checkoutBranch(b)) },
|
||||
...(b.remote
|
||||
? []
|
||||
: [
|
||||
{
|
||||
label: "Checkout and Update",
|
||||
disabled: !b.upstream || updating || !!existingWorktree,
|
||||
run: run(() => checkoutAndUpdate(b)),
|
||||
},
|
||||
]),
|
||||
...(existingWorktree && !b.remote
|
||||
? [{ label: "Open Existing Worktree", icon: "folder", run: run(() => openWorktree(existingWorktree, true)) }]
|
||||
: []),
|
||||
@@ -327,6 +337,15 @@ export function commonBranchMenu(
|
||||
const base = bases[0];
|
||||
const items: MenuItem[] = [
|
||||
{ label: "Checkout", run: run(() => checkoutInRepos(b, roots)) },
|
||||
...(b.remote
|
||||
? []
|
||||
: [
|
||||
{
|
||||
label: "Checkout and Update",
|
||||
disabled: !b.upstream || !!useVcs.getState().remoteBusy || checkedOutInWorktree,
|
||||
run: run(() => checkoutAndUpdate(b, roots)),
|
||||
},
|
||||
]),
|
||||
newFrom,
|
||||
worktree,
|
||||
...(bases.every(Boolean)
|
||||
|
||||
@@ -1376,6 +1376,27 @@ export async function checkoutAndRebase({ branch, repos }: CheckoutRebaseTarget)
|
||||
});
|
||||
}
|
||||
|
||||
/**
|
||||
* Checkout and Update on a local branch: checks it out (in `roots`, or the
|
||||
* current repository), then updates it like Update does, in each repository
|
||||
* where the checkout took place.
|
||||
*/
|
||||
export async function checkoutAndUpdate(branch: NamedBranch, roots?: readonly string[]) {
|
||||
const project = useProject.getState().project;
|
||||
if (roots) await checkoutInRepos(branch, roots);
|
||||
else await checkoutBranch(branch);
|
||||
if (useProject.getState().project !== project) return;
|
||||
const repos: readonly (string | null)[] = roots ?? [currentRepo()];
|
||||
const heads = await Promise.all(
|
||||
repos.map(async (repo) => [repo, await call(commands.vcsBranchInfo(repo)).catch(() => null)] as const),
|
||||
);
|
||||
if (useProject.getState().project !== project) return;
|
||||
const targets = heads
|
||||
.filter(([, info]) => info?.head === branch.name)
|
||||
.map(([repo]) => ({ repo: repo ?? undefined, branch }));
|
||||
if (targets.length) await updateBranches(targets);
|
||||
}
|
||||
|
||||
export type BranchUpdateTarget = { repo?: string; branch?: Pick<Branch, "name" | "remote"> };
|
||||
|
||||
/** Update the named branches. Checked-out branches follow the configured update method. */
|
||||
|
||||
@@ -3645,6 +3645,7 @@
|
||||
"Shelve Silently": "Shelve Silently",
|
||||
"Unshelve Silently": "Unshelve Silently",
|
||||
"Fold Lines Like This": "Fold Lines Like This",
|
||||
"Pause Output": "Pause Output",
|
||||
"Remove All Watches": "Remove All Watches",
|
||||
"Not Cherry-Picked Commits": "Not Cherry-Picked Commits",
|
||||
"Show Branch Diff": "Show Branch Diff",
|
||||
@@ -3658,6 +3659,7 @@
|
||||
"Stopped highlighting unpicked commits from '{source}' after the branch filter changed": "Stopped highlighting unpicked commits from '{source}' after the branch filter changed",
|
||||
"Checkout and Rebase": "Checkout and Rebase",
|
||||
"Checkout and Rebase onto Current": "Checkout and Rebase onto Current",
|
||||
"Checkout and Update": "Checkout and Update",
|
||||
"Checkout and Rebase failed": "Checkout and Rebase failed",
|
||||
"Checkout and Rebase requires an existing commit": "Checkout and Rebase requires an existing commit",
|
||||
"Checked out and rebased '{branchName}'": "Checked out and rebased '{branchName}'",
|
||||
|
||||
@@ -3905,6 +3905,7 @@
|
||||
"Hold Shift to Run, F4 to edit, Delete to remove": "Удерживайте Shift для запуска, F4 — для редактирования, Delete — для удаления",
|
||||
"Send EOF": "Отправить EOF",
|
||||
"Fold Lines Like This": "Свернуть похожие строки",
|
||||
"Pause Output": "Приостановить вывод",
|
||||
"Collapse folded lines": "Сворачивать свернутые строки",
|
||||
"Close Tool Window Tab": "Закрыть вкладку окна инструментов",
|
||||
"No open files": "Нет открытых файлов",
|
||||
@@ -5615,6 +5616,7 @@
|
||||
"Stopped highlighting unpicked commits from '{source}' after the branch filter changed": "Подсветка неперенесённых коммитов из '{source}' остановлена после изменения фильтра веток",
|
||||
"Checkout and Rebase": "Переключиться и перебазировать",
|
||||
"Checkout and Rebase onto Current": "Переключиться и перебазировать на текущую",
|
||||
"Checkout and Update": "Переключиться и обновить",
|
||||
"Checkout and Rebase failed": "Не удалось переключиться и перебазировать",
|
||||
"Checkout and Rebase requires an existing commit": "Для переключения и перебазирования требуется существующий коммит",
|
||||
"Checked out and rebased '{branchName}'": "Выполнено переключение и перебазирование '{branchName}'",
|
||||
|
||||
@@ -2757,6 +2757,7 @@
|
||||
"Shelve Silently": "Bildirim Vermeden Rafa Al",
|
||||
"Unshelve Silently": "Bildirim Vermeden Raftan Çıkar",
|
||||
"Fold Lines Like This": "Buna Benzer Satırları Daralt",
|
||||
"Pause Output": "Çıktıyı Duraklat",
|
||||
"Remove All Watches": "İzlenen Tüm İfadeleri Kaldır",
|
||||
"GitHub account": "GitHub hesabı",
|
||||
"Leave empty to use the active GitHub CLI account. OpenIDEA resolves the token at launch and never stores it.": "Etkin GitHub CLI hesabını kullanmak için boş bırakın. OpenIDEA tokeni başlatma sırasında çözümler ve saklamaz.",
|
||||
|
||||
@@ -3474,6 +3474,7 @@
|
||||
"Hold Shift to Run, F4 to edit, Delete to remove": "按住 Shift 執行,F4 編輯,Delete 刪除",
|
||||
"Send EOF": "傳送 EOF",
|
||||
"Fold Lines Like This": "摺疊與此類似的行",
|
||||
"Pause Output": "暫停輸出",
|
||||
"Collapse folded lines": "摺疊行",
|
||||
"Close Tool Window Tab": "關閉工具視窗分頁",
|
||||
"No open files": "沒有開啟的檔案",
|
||||
|
||||
@@ -4039,6 +4039,7 @@
|
||||
"Hold Shift to Run, F4 to edit, Delete to remove": "按住 Shift 运行,F4 编辑,Delete 删除",
|
||||
"Send EOF": "发送 EOF",
|
||||
"Fold Lines Like This": "折叠与此类似的行",
|
||||
"Pause Output": "暂停输出",
|
||||
"Collapse folded lines": "折叠行",
|
||||
"Close Tool Window Tab": "关闭工具窗口标签页",
|
||||
"No open files": "没有打开的文件",
|
||||
@@ -5759,6 +5760,7 @@
|
||||
"Stopped highlighting unpicked commits from '{source}' after the branch filter changed": "分支筛选已更改,停止高亮 '{source}' 中未拣选的提交",
|
||||
"Checkout and Rebase": "签出并变基",
|
||||
"Checkout and Rebase onto Current": "签出并变基到当前分支",
|
||||
"Checkout and Update": "签出并更新",
|
||||
"Checkout and Rebase failed": "签出并变基失败",
|
||||
"Checkout and Rebase requires an existing commit": "签出并变基需要已有提交",
|
||||
"Checked out and rebased '{branchName}'": "已签出并变基 '{branchName}'",
|
||||
|
||||
Reference in new issue
Заблокувати користувача