дзеркало
https://github.com/l0ng-ai/openidea.git
синхронізовано 2026-12-06 10:07:11 +02:00
fix(vcs): keep the log mounted while another Git tab is shown
Switching from Console or Worktrees back to Log rebuilt the commit list, graph, branch tree and details, and reloaded the log, refs and branches. The last log tab shown now stays mounted, hidden with content-visibility, so switching back to it is a plain show.
Цей коміт міститься в:
1 джерело
5c592bbc86
коміт
07653129fc
2 files changed
+40
-5
No files matched your search
@@ -1,9 +1,26 @@
|
||||
.root {
|
||||
position: relative;
|
||||
flex: 1;
|
||||
min-height: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
/* Absolute in both states, so hiding and showing the log doesn't lay it out again. */
|
||||
.logHost {
|
||||
position: absolute;
|
||||
inset: 0;
|
||||
display: flex;
|
||||
flex-direction: column;
|
||||
}
|
||||
.logHidden {
|
||||
content-visibility: hidden;
|
||||
z-index: -1;
|
||||
}
|
||||
/* WebKit leaves a stale selection highlight on a subtree whose rendering was skipped when the selection cleared. */
|
||||
.logHidden[data-selection] {
|
||||
content-visibility: visible;
|
||||
opacity: 0;
|
||||
}
|
||||
.headerTabs {
|
||||
min-width: 0;
|
||||
border: 0;
|
||||
|
||||
@@ -14,6 +14,7 @@ import {
|
||||
useFrozenWhileWindowResizes,
|
||||
} from "@/ui";
|
||||
import { copySelectionOnKeyDown } from "@/ui/selectableText";
|
||||
import { useSelectionVisibility } from "@/ui/useSelectionBoundary";
|
||||
import { spanStyle } from "@/ui/ansi";
|
||||
import clsx from "clsx";
|
||||
import { useContext, useEffect, useLayoutEffect, useRef, useState } from "react";
|
||||
@@ -34,6 +35,7 @@ import { LogScope } from "./LogScope";
|
||||
import {
|
||||
closeLogTab,
|
||||
initLogBranchFilter,
|
||||
isLogTab,
|
||||
logState,
|
||||
refsSignature,
|
||||
reloadLog,
|
||||
@@ -85,6 +87,15 @@ export function GitToolWindow() {
|
||||
// window drag; they follow the window once it stops.
|
||||
const root = useRef<HTMLDivElement>(null);
|
||||
useFrozenWhileWindowResizes(root);
|
||||
// The last log tab shown stays mounted (hidden, keeping its layout) while another tab is shown,
|
||||
// so switching back to it neither rebuilds its rows, graph and branch tree nor reloads it.
|
||||
const logTabs = useGitLog((s) => s.logTabs);
|
||||
const logShown = isLogTab(shown, logTabs);
|
||||
const [lastLog, setLastLog] = useState<string | null>(null);
|
||||
if (logShown && lastLog !== shown) setLastLog(shown);
|
||||
const keptLog = logShown ? shown : lastLog && isLogTab(lastLog, logTabs) ? lastLog : null;
|
||||
const logHost = useRef<HTMLDivElement>(null);
|
||||
useSelectionVisibility(logHost, !!keptLog);
|
||||
if (!available && !external)
|
||||
return (
|
||||
<EmptyState title="Version control is not configured">
|
||||
@@ -107,11 +118,18 @@ export function GitToolWindow() {
|
||||
<ConsoleView />
|
||||
) : shown === "worktrees" ? (
|
||||
<WorktreesPanel className={styles.worktrees} listClassName={styles.worktreeList} />
|
||||
) : (
|
||||
// Each log tab has its own view (its filters and commits are swapped into the store).
|
||||
<LogScope id={shown}>
|
||||
<LogView key={shown} />
|
||||
</LogScope>
|
||||
) : null}
|
||||
{keptLog && (
|
||||
<div
|
||||
ref={logHost}
|
||||
className={clsx(styles.logHost, !logShown && styles.logHidden)}
|
||||
aria-hidden={logShown ? undefined : true}
|
||||
>
|
||||
{/* Each log tab has its own view (its filters and commits are swapped into the store). */}
|
||||
<LogScope id={keptLog}>
|
||||
<LogView key={keptLog} />
|
||||
</LogScope>
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
);
|
||||
|
||||
Reference in new issue
Заблокувати користувача