дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-11-29 22:02:59 +02:00
Порівняти коміти
| Автор | SHA1 | Дата | |
|---|---|---|---|
|
|
3322ecc527 |
No files matched your search
@@ -151,7 +151,6 @@ pub struct CommitSettings {
|
||||
/// Commit from the Commit tool window; off = Local Changes in the Git tool
|
||||
/// window and a Commit dialog.
|
||||
pub non_modal: bool,
|
||||
pub include_changes_by_default: bool,
|
||||
/// Start with an empty message instead of the last one / the changelist's.
|
||||
pub clear_initial_message: bool,
|
||||
pub analyze_code: bool,
|
||||
@@ -191,7 +190,6 @@ impl Default for CommitSettings {
|
||||
fn default() -> Self {
|
||||
Self {
|
||||
non_modal: true,
|
||||
include_changes_by_default: true,
|
||||
clear_initial_message: false,
|
||||
analyze_code: true,
|
||||
check_todo: true,
|
||||
|
||||
@@ -898,16 +898,6 @@ mod tests {
|
||||
);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn commit_default_inclusion_persists() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
let store = SettingsStore::load(tmp.path(), None);
|
||||
assert!(store.effective().vcs.commit.include_changes_by_default);
|
||||
let settings = store.set(SettingsScope::Global, "vcs.commit.includeChangesByDefault", json!(false)).unwrap();
|
||||
assert!(!settings.vcs.commit.include_changes_by_default);
|
||||
assert!(!SettingsStore::load(tmp.path(), None).effective().vcs.commit.include_changes_by_default);
|
||||
}
|
||||
|
||||
#[test]
|
||||
fn inspection_profiles_live_in_their_layers() {
|
||||
let tmp = tempfile::tempdir().unwrap();
|
||||
|
||||
@@ -76,34 +76,6 @@ test("⌘K commits the checked changes with the typed message", async ({ workben
|
||||
await expect(changes.getByRole("checkbox", { name: "Include build.gradle.kts in commit" })).toBeHidden();
|
||||
});
|
||||
|
||||
test("turning off default inclusion starts Commit with all files unchecked", async ({ workbench: page }) => {
|
||||
await page.keyboard.press("Meta+,");
|
||||
const settings = page.getByRole("dialog", { name: "Settings", exact: true });
|
||||
const label = "Include changes in the commit by default";
|
||||
await settings.getByRole("textbox", { name: "Search settings" }).fill(label);
|
||||
await settings.getByRole("treeitem", { name: "Commit", exact: true }).click();
|
||||
const toggle = settings.getByRole("checkbox", { name: label, exact: true });
|
||||
await expect(toggle).toBeChecked();
|
||||
await toggle.click();
|
||||
await settings.getByRole("button", { name: "OK", exact: true }).click();
|
||||
await expect(settings).not.toBeVisible();
|
||||
|
||||
await stubRepository(page);
|
||||
await page.keyboard.press("Meta+k");
|
||||
const panel = page.getByRole("region", { name: "Commit", exact: true });
|
||||
const changes = panel.getByRole("tree", { name: "Changes" });
|
||||
const tracked = changes.getByRole("checkbox", { name: "Include build.gradle.kts in commit" });
|
||||
await expect(tracked).toHaveAttribute("aria-checked", "false");
|
||||
await expect(changes.getByRole("checkbox", { name: "Include Unversioned Files in commit" })).not.toBeChecked();
|
||||
await tracked.click();
|
||||
await expect(tracked).toBeChecked();
|
||||
await panel.getByRole("textbox", { name: "Commit message" }).fill("Commit the selected file");
|
||||
await panel.getByRole("button", { name: "Commit", exact: true }).click();
|
||||
await expect.poll(() => ipcCalls(page, "vcs_commit")).toHaveLength(1);
|
||||
const [committed] = await ipcCalls(page, "vcs_commit");
|
||||
expect(committed!.options).toMatchObject({ stage: [`${ROOT}/build.gradle.kts`] });
|
||||
});
|
||||
|
||||
test("commit message history opens above the message without an empty icon column", async ({ workbench: page }) => {
|
||||
await stubRepository(page);
|
||||
await page.keyboard.press("Meta+k");
|
||||
|
||||
@@ -71,17 +71,12 @@ test("⌘1 focuses, hides and re-shows the Project tool window", async ({ workbe
|
||||
|
||||
test("⌘4 toggles Run; Shift+Escape hides the active tool window", async ({ workbench: page }) => {
|
||||
const run = page.getByRole("region", { name: "Run" });
|
||||
// The shortcut hides the window only once it is active: activation focuses it a frame after it shows.
|
||||
const focusedInRun = () =>
|
||||
expect.poll(() => page.evaluate(() => !!document.activeElement?.closest('[data-toolwindow="run"]'))).toBe(true);
|
||||
await page.keyboard.press("Meta+4");
|
||||
await expect(run).toBeVisible();
|
||||
await focusedInRun();
|
||||
await page.keyboard.press("Meta+4");
|
||||
await expect(run).toBeHidden();
|
||||
await page.keyboard.press("Meta+4");
|
||||
await expect(run).toBeVisible();
|
||||
await focusedInRun();
|
||||
await page.keyboard.press("Shift+Escape");
|
||||
await expect(run).toBeHidden();
|
||||
});
|
||||
|
||||
@@ -3906,7 +3906,6 @@ export type CommitSettings = {
|
||||
* window and a Commit dialog.
|
||||
*/
|
||||
nonModal?: boolean,
|
||||
includeChangesByDefault?: boolean,
|
||||
/** Start with an empty message instead of the last one / the changelist's. */
|
||||
clearInitialMessage?: boolean,
|
||||
analyzeCode?: boolean,
|
||||
|
||||
@@ -571,10 +571,7 @@ describe("DocumentManager + slots", () => {
|
||||
if (id === a.doc) throw new Error("disk full");
|
||||
await save(id);
|
||||
});
|
||||
const logged = vi.spyOn(console, "error").mockImplementation(() => {});
|
||||
await expect(manager.saveAll("explicit")).rejects.toThrow("disk full");
|
||||
expect(logged).toHaveBeenCalledWith("saving /p/a.txt failed", expect.objectContaining({ message: "disk full" }));
|
||||
logged.mockRestore();
|
||||
expect(backend.files.get("/p/a.txt")).toBe("a\n");
|
||||
expect(backend.files.get("/p/b.txt")).toBe("changed b\n");
|
||||
expect(a.getMeta().dirty).toBe(true);
|
||||
|
||||
@@ -927,7 +927,7 @@ export class DocumentManager {
|
||||
try {
|
||||
await model.save("auto");
|
||||
} catch (e) {
|
||||
logError(`autosave of ${model.path} failed`, e);
|
||||
console.warn(`autosave of ${model.path} failed`, e);
|
||||
}
|
||||
}
|
||||
// As in IDEA, a file whose changes are not saved (autosave off, or a failed save) stays
|
||||
@@ -985,8 +985,6 @@ export class DocumentManager {
|
||||
.filter((m) => !(skipUntitled && isUntitledUri(m.path)))
|
||||
.map((m) =>
|
||||
m.save(reason).catch((e) => {
|
||||
// The notification shows the message only; the log keeps the stack for reports.
|
||||
logError(`saving ${m.path} failed`, e);
|
||||
errors.push(e);
|
||||
}),
|
||||
),
|
||||
|
||||
@@ -37,17 +37,6 @@ describe("markdown LaTeX math", () => {
|
||||
expect(root.querySelector("p")?.textContent?.startsWith("Prices $5 and $10, with ")).toBe(true);
|
||||
});
|
||||
|
||||
it("leaves separate code spans inside dollar signs as code", () => {
|
||||
const root = parseSafe("($`x` `y`$)");
|
||||
expect(root.querySelector("p")?.innerHTML).toBe("($<code>x</code> <code>y</code>$)");
|
||||
});
|
||||
|
||||
it("matches a longer backtick delimiter around math inside emphasis", () => {
|
||||
const root = parseSafe("**($``x` + y``$)**");
|
||||
expect(root.querySelector("strong .katex annotation")?.textContent).toBe("x` + y");
|
||||
expect(root.querySelector("code")).toBeNull();
|
||||
});
|
||||
|
||||
it("keeps an unfinished protected delimiter from swallowing a later formula", () => {
|
||||
const root = parseSafe("Unfinished $`x` and $y$.");
|
||||
expect(root.querySelector("p > code")?.textContent).toBe("x");
|
||||
|
||||
@@ -39,10 +39,9 @@ function findClosingDelimiter(src: string, from: number, delim: string): number
|
||||
return -1;
|
||||
}
|
||||
|
||||
// The first backtick run of the opening length ends the code span.
|
||||
const PROTECTED_INLINE_DOLLAR = /^\$(?<ticks>`+)(?!`)(?<tex>(?:[^`\r\n]|(?!\k<ticks>(?!`))`+(?!`))+)\k<ticks>\$/;
|
||||
const PROTECTED_INLINE_DOLLAR = /^\$`([^`\r\n]+)`\$/;
|
||||
// Marked masks code spans as `[aaa]` before calling emStrongMask
|
||||
const MASKED_PROTECTED_INLINE_DOLLAR = /^\$\[(?<tex>a+)\]\$/;
|
||||
const MASKED_PROTECTED_INLINE_DOLLAR = /^\$\[(a+)\]\$/;
|
||||
|
||||
/**
|
||||
* Matches inline `$...$` from index 0 using Pandoc-style guards so currency
|
||||
@@ -88,7 +87,7 @@ function matchInlineMath(
|
||||
if (src[0] === "$") {
|
||||
const match = protectedDollar.exec(src);
|
||||
if (match) {
|
||||
const text = match.groups!.tex!;
|
||||
const text = match[1]!;
|
||||
return text.trim() ? { raw: match[0], text, display: false } : null;
|
||||
}
|
||||
if (src[1] === "`") return null;
|
||||
|
||||
@@ -643,11 +643,6 @@ export const VCS_PAGES: PageSpec[] = [
|
||||
label: "Use non-modal commit interface",
|
||||
hint: "When off, Local Changes and Stash are tabs of the Git tool window and Commit opens a dialog.",
|
||||
},
|
||||
{
|
||||
kind: "toggle",
|
||||
key: "vcs.commit.includeChangesByDefault",
|
||||
label: "Include changes in the commit by default",
|
||||
},
|
||||
{ kind: "toggle", key: "vcs.commit.clearInitialMessage", label: "Clear initial commit message" },
|
||||
],
|
||||
},
|
||||
|
||||
@@ -422,51 +422,6 @@ describe("terminal open", () => {
|
||||
});
|
||||
});
|
||||
|
||||
describe("deferred terminal focus", () => {
|
||||
function openable(key: string) {
|
||||
const container = document.createElement("div");
|
||||
document.body.appendChild(container);
|
||||
const session = new TerminalSession({ key, cwd: "/tmp", onChange: () => undefined, onFocus: () => undefined });
|
||||
Object.defineProperty(session.host, "offsetWidth", { configurable: true, get: () => 400 });
|
||||
Object.defineProperty(session.host, "offsetHeight", { configurable: true, get: () => 300 });
|
||||
const textarea = document.createElement("textarea");
|
||||
vi.spyOn(session.term, "open").mockImplementation(() => undefined);
|
||||
Object.defineProperty(session.term, "textarea", { configurable: true, get: () => textarea });
|
||||
const focus = vi.spyOn(session.term, "focus").mockImplementation(() => undefined);
|
||||
return { container, session, focus };
|
||||
}
|
||||
|
||||
afterEach(() => vi.useRealTimers());
|
||||
|
||||
it("takes the caret once xterm opens when focus stayed put", () => {
|
||||
vi.useFakeTimers();
|
||||
const { container, session, focus } = openable("s-stay");
|
||||
session.focus();
|
||||
session.attach(container);
|
||||
vi.advanceTimersByTime(FIT_SETTLE_MS);
|
||||
expect(focus).toHaveBeenCalledTimes(1);
|
||||
session.dispose();
|
||||
container.remove();
|
||||
});
|
||||
|
||||
it("leaves focus that moved elsewhere before xterm opened", () => {
|
||||
vi.useFakeTimers();
|
||||
const { container, session, focus } = openable("s-moved");
|
||||
const tree = document.createElement("div");
|
||||
tree.tabIndex = 0;
|
||||
document.body.appendChild(tree);
|
||||
session.focus();
|
||||
tree.focus();
|
||||
session.attach(container);
|
||||
vi.advanceTimersByTime(FIT_SETTLE_MS);
|
||||
expect(focus).not.toHaveBeenCalled();
|
||||
expect(document.activeElement).toBe(tree);
|
||||
session.dispose();
|
||||
container.remove();
|
||||
tree.remove();
|
||||
});
|
||||
});
|
||||
|
||||
describe("terminal font zoom", () => {
|
||||
afterEach(() => {
|
||||
unbindTerminals();
|
||||
|
||||
@@ -254,8 +254,6 @@ export class TerminalSession {
|
||||
private opened = false;
|
||||
/** `focus()` arrived before the textarea existed (the pane is focused while xterm is still closed). */
|
||||
private pendingFocus = false;
|
||||
/** What had focus when `pendingFocus` was set: a later move elsewhere cancels it. */
|
||||
private pendingFocusFrom: Element | null = null;
|
||||
/** Bounds retries when the pane has no box yet, or xterm cannot measure a cell. */
|
||||
private fitAttempts = 0;
|
||||
private disposed = false;
|
||||
@@ -681,17 +679,7 @@ export class TerminalSession {
|
||||
this.opts.onFocus(this.key);
|
||||
});
|
||||
this.watchImeCommit();
|
||||
if (this.pendingFocus) {
|
||||
this.pendingFocus = false;
|
||||
if (this.focusStayedHere()) this.focus();
|
||||
}
|
||||
}
|
||||
|
||||
/** Whether focus is still where the deferred `focus()` left it, or in this terminal's own window. */
|
||||
private focusStayedHere(): boolean {
|
||||
const active = document.activeElement;
|
||||
if (!active || active === document.body || active === this.pendingFocusFrom) return true;
|
||||
return this.host.contains(active) || !!this.host.closest("[data-toolwindow]")?.contains(active);
|
||||
if (this.pendingFocus) this.focus();
|
||||
}
|
||||
|
||||
detach(container: HTMLElement) {
|
||||
@@ -1002,7 +990,6 @@ export class TerminalSession {
|
||||
this.clearUnseenDone();
|
||||
if (!this.opened || !this.term.textarea) {
|
||||
this.pendingFocus = true;
|
||||
this.pendingFocusFrom = document.activeElement;
|
||||
this.scheduleFit();
|
||||
return;
|
||||
}
|
||||
|
||||
@@ -3,7 +3,7 @@
|
||||
* parts also make the Git window's Local Changes / Stash tabs and the Commit dialog.
|
||||
*/
|
||||
import { writeClipboardText } from "@/platform/clipboard";
|
||||
import { useWorkflowSettings, workflowSettings } from "@/platform/workflowSettings";
|
||||
import { useWorkflowSettings } from "@/platform/workflowSettings";
|
||||
import { formatBinding, isMacHost, macStroke, normalizeBinding, shortcutLabel, strokeOf } from "@/platform/keymap";
|
||||
import {
|
||||
useCallback,
|
||||
@@ -536,11 +536,7 @@ function useCommitChecks() {
|
||||
export function useIncludedCount(): number {
|
||||
const status = useVcs((s) => s.status);
|
||||
const checks = useCommitChecks();
|
||||
const includeByDefault = useWorkflowSettings((s) => s.vcs.commit.includeChangesByDefault);
|
||||
return useMemo(
|
||||
() => planCommit(status, checks, includeByDefault).included.length,
|
||||
[status, checks, includeByDefault],
|
||||
);
|
||||
return useMemo(() => planCommit(status, checks).included.length, [status, checks]);
|
||||
}
|
||||
|
||||
/**
|
||||
@@ -645,7 +641,6 @@ export function ChangesTree({ mode }: { mode: "commit" | "local" | "dialog" }) {
|
||||
const changelists = useChangelists((s) => s.state);
|
||||
const lists = staging ? undefined : changelists;
|
||||
const checks = useCommitChecks();
|
||||
const includeByDefault = useWorkflowSettings((s) => s.vcs.commit.includeChangesByDefault);
|
||||
const checkboxes = mode !== "local" && !staging;
|
||||
const [dropTarget, setDropTarget] = useState<string | null>(null);
|
||||
// IDEA starts with Unversioned Files collapsed.
|
||||
@@ -760,12 +755,10 @@ export function ChangesTree({ mode }: { mode: "commit" | "local" | "dialog" }) {
|
||||
const files = filesOf(nodes);
|
||||
const { status: st, root: r } = useVcs.getState();
|
||||
const cur = withListDefaults(st, r ?? "", useChangelists.getState().state, useCommit.getState().checks);
|
||||
const includeByDefault = workflowSettings().vcs.commit.includeChangesByDefault;
|
||||
const agg = aggregateCheck(files, cur, includeByDefault);
|
||||
const agg = aggregateCheck(files, cur);
|
||||
const target = agg.on === files.length && !agg.indeterminate ? "none" : "all";
|
||||
const next = new Map(cur);
|
||||
for (const f of files)
|
||||
next.set(f.path, files.length === 1 ? toggledCheck(checkOf(f, cur, includeByDefault)) : target);
|
||||
for (const f of files) next.set(f.path, files.length === 1 ? toggledCheck(checkOf(f, cur)) : target);
|
||||
useCommit.setState({ checks: next });
|
||||
}, []);
|
||||
|
||||
@@ -941,7 +934,7 @@ export function ChangesTree({ mode }: { mode: "commit" | "local" | "dialog" }) {
|
||||
</span>
|
||||
}
|
||||
renderNode={(n, st) => {
|
||||
const agg = aggregateCheck(n.files, checks, includeByDefault);
|
||||
const agg = aggregateCheck(n.files, checks);
|
||||
const label = (
|
||||
<span
|
||||
className={clsx(
|
||||
@@ -1330,7 +1323,7 @@ function CommitPanel({ included }: { included: number }) {
|
||||
|
||||
return (
|
||||
<div className={styles.commit}>
|
||||
<CommitMessageField included={included} runner={runner} autoFocus />
|
||||
<CommitMessageField included={included} runner={runner} />
|
||||
<div className={styles.commitActions}>
|
||||
<Button variant="primary" disabled={!canCommit} onClick={() => void runner.run(false)} title="⌘↩">
|
||||
<T>{commitLabel(amend, checkProblems.length > 0, commitAll)}</T>
|
||||
|
||||
@@ -433,19 +433,6 @@ describe("commit inclusion", () => {
|
||||
expect(initialCheck(status[5]!)).toBe("none");
|
||||
});
|
||||
|
||||
it("starts all files unchecked when default inclusion is disabled", () => {
|
||||
const checks = new Map<string, CheckState>();
|
||||
expect(aggregateCheck(status, checks, false)).toEqual({ checked: false, indeterminate: false, on: 0 });
|
||||
expect(planCommit(status, checks, false)).toEqual({
|
||||
included: [],
|
||||
stage: [],
|
||||
exclude: ["/r/src/main/kotlin/Partial.kt", "/r/src/test/AppTest.kt", "/r/README.md"],
|
||||
partial: [],
|
||||
});
|
||||
checks.set(status[0]!.path, "all");
|
||||
expect(planCommit(status, checks, false).included).toEqual([status[0]]);
|
||||
});
|
||||
|
||||
it("plans which changes the commit takes and which staged ones it leaves out", () => {
|
||||
const checks = new Map<string, CheckState>([
|
||||
["/r/README.md", "none"],
|
||||
|
||||
@@ -75,28 +75,23 @@ export function isPartiallyStaged(fs: FileStatus): boolean {
|
||||
);
|
||||
}
|
||||
|
||||
export function initialCheck(fs: FileStatus, includeByDefault = true): CheckState {
|
||||
if (!includeByDefault) return "none";
|
||||
export function initialCheck(fs: FileStatus): CheckState {
|
||||
const g = groupOf(fs);
|
||||
// Unversioned files and unresolved conflicts are opt-in, as in IDEA.
|
||||
if (g !== "changes") return "none";
|
||||
return isPartiallyStaged(fs) ? "staged" : "all";
|
||||
}
|
||||
|
||||
export function checkOf(fs: FileStatus, checks: ReadonlyMap<string, CheckState>, includeByDefault = true): CheckState {
|
||||
return checks.get(fs.path) ?? initialCheck(fs, includeByDefault);
|
||||
export function checkOf(fs: FileStatus, checks: ReadonlyMap<string, CheckState>): CheckState {
|
||||
return checks.get(fs.path) ?? initialCheck(fs);
|
||||
}
|
||||
|
||||
/** Aggregate checkbox state for a set of files. */
|
||||
export function aggregateCheck(
|
||||
files: readonly FileStatus[],
|
||||
checks: ReadonlyMap<string, CheckState>,
|
||||
includeByDefault = true,
|
||||
) {
|
||||
export function aggregateCheck(files: readonly FileStatus[], checks: ReadonlyMap<string, CheckState>) {
|
||||
let on = 0;
|
||||
let partial = false;
|
||||
for (const f of files) {
|
||||
const c = checkOf(f, checks, includeByDefault);
|
||||
const c = checkOf(f, checks);
|
||||
if (c !== "none") on++;
|
||||
if (c === "staged" || c === "hunks") partial = true;
|
||||
}
|
||||
@@ -415,11 +410,7 @@ export function renamedFromPath(fs: FileStatus): string | null {
|
||||
}
|
||||
|
||||
/** What the commit takes beyond the index, and what staged changes it leaves out. */
|
||||
export function planCommit(
|
||||
status: readonly FileStatus[],
|
||||
checks: ReadonlyMap<string, CheckState>,
|
||||
includeByDefault = true,
|
||||
): CommitPlan {
|
||||
export function planCommit(status: readonly FileStatus[], checks: ReadonlyMap<string, CheckState>): CommitPlan {
|
||||
const plan: CommitPlan = { stage: [], exclude: [], included: [], partial: [] };
|
||||
for (const fs of status) {
|
||||
if (!groupOf(fs)) {
|
||||
@@ -432,7 +423,7 @@ export function planCommit(
|
||||
if (fs.staged && fs.staged !== "conflicted" && fs.unstaged !== "ignored") plan.exclude.push(stripSlash(fs.path));
|
||||
continue;
|
||||
}
|
||||
const c = checkOf(fs, checks, includeByDefault);
|
||||
const c = checkOf(fs, checks);
|
||||
const path = stripSlash(fs.path);
|
||||
if (c === "none") {
|
||||
if (fs.staged && fs.staged !== "conflicted") {
|
||||
|
||||
@@ -6,7 +6,7 @@
|
||||
*/
|
||||
import type { CommitOptions, CommitSelection, PartialCommitFile } from "@/bindings";
|
||||
import { call, commands } from "@/platform/ipc";
|
||||
import { onWorkflowSettingsChange, workflowSettings } from "@/platform/workflowSettings";
|
||||
import { workflowSettings } from "@/platform/workflowSettings";
|
||||
import {
|
||||
maybeEditorService,
|
||||
provideCommitService,
|
||||
@@ -34,10 +34,6 @@ export function installDraftRevision(): () => void {
|
||||
revision++;
|
||||
});
|
||||
const offLists = useChangelists.subscribe(() => void revision++);
|
||||
const offDefault = onWorkflowSettingsChange(
|
||||
(s) => s.vcs.commit.includeChangesByDefault,
|
||||
() => void revision++,
|
||||
);
|
||||
const offRepo = useVcs.subscribe((s, p) => {
|
||||
// With the staging area the index is the inclusion: a status change may change the commit.
|
||||
if (s.root !== p.root || (s.status !== p.status && stagingAreaOn())) revision++;
|
||||
@@ -45,7 +41,6 @@ export function installDraftRevision(): () => void {
|
||||
return () => {
|
||||
offCommit();
|
||||
offLists();
|
||||
offDefault();
|
||||
offRepo();
|
||||
};
|
||||
}
|
||||
@@ -54,7 +49,7 @@ export function installDraftRevision(): () => void {
|
||||
export function currentPlan(): CommitPlan {
|
||||
const { status, root } = useVcs.getState();
|
||||
const checks = inclusionChecks(status, root ?? "", useChangelists.getState().state, useCommit.getState().checks);
|
||||
return planCommit(status, checks, workflowSettings().vcs.commit.includeChangesByDefault);
|
||||
return planCommit(status, checks);
|
||||
}
|
||||
|
||||
/**
|
||||
|
||||
@@ -9,7 +9,6 @@ import { EditorView, GutterMarker, ViewPlugin, gutter, type ViewUpdate } from "@
|
||||
import type { LineHunk } from "@/bindings";
|
||||
import { tx } from "@/platform/i18n";
|
||||
import { commands } from "@/platform/ipc";
|
||||
import { onWorkflowSettingsChange, workflowSettings } from "@/platform/workflowSettings";
|
||||
import { checkOf, hunkIncluded, toggledHunk } from "./changes";
|
||||
import { useChangelists, withListDefaults } from "./changelists";
|
||||
import { stagingAreaOn } from "./staging";
|
||||
@@ -40,8 +39,7 @@ function inclusionOf(path: string) {
|
||||
const { status, root } = useVcs.getState();
|
||||
const { checks, excludedHunks } = useCommit.getState();
|
||||
const effective = withListDefaults(status, root ?? "", useChangelists.getState().state, checks);
|
||||
const check = checkOf(fs, effective, workflowSettings().vcs.commit.includeChangesByDefault);
|
||||
return { key: fs.path, check, excluded: excludedHunks.get(fs.path) };
|
||||
return { key: fs.path, check: checkOf(fs, effective), excluded: excludedHunks.get(fs.path) };
|
||||
}
|
||||
|
||||
/** Includes / excludes one changed block of `path`; `all` are the keys of every block. */
|
||||
@@ -99,14 +97,12 @@ export function inclusionGutter(path: string, base: string): Extension {
|
||||
seq = 0;
|
||||
live = true;
|
||||
unsubscribe: () => void;
|
||||
unsubscribeDefault: () => void;
|
||||
constructor(readonly view: EditorView) {
|
||||
this.schedule(0);
|
||||
const redraw = () => queueMicrotask(() => this.live && this.view.dispatch({ effects: refresh.of(null) }));
|
||||
this.unsubscribe = useCommit.subscribe((s, p) => {
|
||||
if (s.checks !== p.checks || s.excludedHunks !== p.excludedHunks) redraw();
|
||||
if (s.checks !== p.checks || s.excludedHunks !== p.excludedHunks)
|
||||
queueMicrotask(() => this.live && this.view.dispatch({ effects: refresh.of(null) }));
|
||||
});
|
||||
this.unsubscribeDefault = onWorkflowSettingsChange((s) => s.vcs.commit.includeChangesByDefault, redraw);
|
||||
}
|
||||
update(u: ViewUpdate) {
|
||||
if (u.docChanged) this.schedule(250);
|
||||
@@ -133,7 +129,6 @@ export function inclusionGutter(path: string, base: string): Extension {
|
||||
destroy() {
|
||||
if (this.timer) clearTimeout(this.timer);
|
||||
this.unsubscribe();
|
||||
this.unsubscribeDefault();
|
||||
this.live = false;
|
||||
}
|
||||
},
|
||||
|
||||
@@ -103,7 +103,6 @@ export const CLIENT_SETTINGS_KEYS = [
|
||||
"vcs.git.combineStashAndShelf",
|
||||
"vcs.git.stagingArea",
|
||||
"vcs.commit.nonModal",
|
||||
"vcs.commit.includeChangesByDefault",
|
||||
"vcs.commit.doubleClickOpensDiff",
|
||||
"vcs.commit.showRightMargin",
|
||||
"agents.showContextUsage",
|
||||
|
||||
@@ -1497,7 +1497,6 @@
|
||||
"Imported 1 MCP server from the project.": "Imported 1 MCP server from the project.",
|
||||
"Imported {count} MCP servers from the project.": "Imported {count} MCP servers from the project.",
|
||||
"Servers added to the project's settings file outside OpenIDEA stay off until you turn them on here.": "Servers added to the project's settings file outside OpenIDEA stay off until you turn them on here.",
|
||||
"Include changes in the commit by default": "Include changes in the commit by default",
|
||||
"Show branch and incoming/outgoing commits in the Project view": "Show branch and incoming/outgoing commits in the Project view",
|
||||
"Execute branch operations on all repositories": "Execute branch operations on all repositories",
|
||||
"Only applies to projects with several Git repositories.": "Only applies to projects with several Git repositories.",
|
||||
|
||||
@@ -5693,7 +5693,6 @@
|
||||
"Configure the settings related to version control used in your project": "配置项目中使用的版本控制相关设置",
|
||||
"Use non-modal commit interface": "使用非模态提交界面",
|
||||
"When off, Local Changes and Stash are tabs of the Git tool window and Commit opens a dialog.": "关闭时,本地更改和贮藏作为 Git 工具窗口的标签页显示,提交时打开对话框。",
|
||||
"Include changes in the commit by default": "默认将更改纳入提交",
|
||||
"Clear initial commit message": "清除初始提交消息",
|
||||
"Show options before Update": "更新前显示选项",
|
||||
"Ask for confirmation to drop commits": "删除提交前请求确认",
|
||||
|
||||
@@ -25,15 +25,6 @@ describe("validateWorkflow", () => {
|
||||
expect(sync("off")).toBe(true);
|
||||
});
|
||||
|
||||
it("includes commit changes by default unless explicitly switched off", () => {
|
||||
const inclusion = (includeChangesByDefault: unknown) =>
|
||||
validateWorkflow({ vcs: { commit: { includeChangesByDefault } } }).vcs.commit.includeChangesByDefault;
|
||||
expect(inclusion(undefined)).toBe(true);
|
||||
expect(inclusion(true)).toBe(true);
|
||||
expect(inclusion(false)).toBe(false);
|
||||
expect(inclusion("false")).toBe(true);
|
||||
});
|
||||
|
||||
it("keeps the double-click choice unset until it is made", () => {
|
||||
expect(DEFAULT_WORKFLOW.vcs.commit.doubleClickOpensDiff).toBeNull();
|
||||
expect(validateWorkflow(undefined).vcs.commit.doubleClickOpensDiff).toBeNull();
|
||||
|
||||
@@ -45,7 +45,6 @@ export interface GitSettingsValid {
|
||||
|
||||
export interface CommitSettingsValid {
|
||||
nonModal: boolean;
|
||||
includeChangesByDefault: boolean;
|
||||
clearInitialMessage: boolean;
|
||||
analyzeCode: boolean;
|
||||
checkTodo: boolean;
|
||||
@@ -305,7 +304,6 @@ export const DEFAULT_WORKFLOW: WorkflowSettings = {
|
||||
},
|
||||
commit: {
|
||||
nonModal: true,
|
||||
includeChangesByDefault: true,
|
||||
clearInitialMessage: false,
|
||||
analyzeCode: true,
|
||||
checkTodo: true,
|
||||
@@ -481,7 +479,6 @@ export function validateVcs(raw: unknown): VcsSettingsValid {
|
||||
},
|
||||
commit: {
|
||||
nonModal: bool(c.nonModal, d.commit.nonModal),
|
||||
includeChangesByDefault: bool(c.includeChangesByDefault, d.commit.includeChangesByDefault),
|
||||
clearInitialMessage: bool(c.clearInitialMessage, d.commit.clearInitialMessage),
|
||||
analyzeCode: bool(c.analyzeCode, d.commit.analyzeCode),
|
||||
checkTodo: bool(c.checkTodo, d.commit.checkTodo),
|
||||
|
||||
Reference in new issue
Заблокувати користувача