+ expect(columns[0].style.minWidth).toBe('35086px')
+ rectSpy.mockRestore()
+ })
})
describe('DiffView - 折叠提示行', () => {
diff --git a/src/renderer/src/components/DiffView.tsx b/src/renderer/src/components/DiffView.tsx
index c054877..a529af8 100644
--- a/src/renderer/src/components/DiffView.tsx
+++ b/src/renderer/src/components/DiffView.tsx
@@ -213,13 +213,15 @@ export default function DiffView({
if (w > 0) setCharW(w / 10)
}, [])
+ /** 列宽计算封顶:超长行(base64/压缩产物可达数 MB 单行)达到上限即停,避免逐字符全量遍历;与词级防护阈值同源 */
+ const MAX_COLS_CAP = 5000
const colsOf = (rows: DisplayItem[], pick: (r: DiffRow) => SideCell): number => {
let max = 40
for (const it of rows) {
if (isFold(it)) continue
const t = pick(it).text
if (t) {
- const c = displayCols(t)
+ const c = displayCols(t, MAX_COLS_CAP)
if (c > max) max = c
}
}
diff --git a/src/renderer/src/components/Toolbar.test.tsx b/src/renderer/src/components/Toolbar.test.tsx
index 17331be..92883d2 100644
--- a/src/renderer/src/components/Toolbar.test.tsx
+++ b/src/renderer/src/components/Toolbar.test.tsx
@@ -5,7 +5,7 @@ import { DiffSummary } from '../diff/diffEngine'
const summary: DiffSummary = { changedLines: 3, inserted: 1, deleted: 1, modified: 1 }
-function setup(extra?: { canExport?: boolean }) {
+function setup() {
const onOptionsChange = vi.fn()
const onNav = vi.fn()
const onExport = vi.fn()
@@ -20,7 +20,6 @@ function setup(extra?: { canExport?: boolean }) {
navCount={3}
onNav={onNav}
onExport={onExport}
- canExport={extra?.canExport ?? true}
onlyDiff={false}
onOnlyDiffChange={onOnlyDiffChange}
onSwap={onSwap}
diff --git a/src/renderer/src/components/Toolbar.tsx b/src/renderer/src/components/Toolbar.tsx
index 5bfad14..6853d28 100644
--- a/src/renderer/src/components/Toolbar.tsx
+++ b/src/renderer/src/components/Toolbar.tsx
@@ -17,7 +17,6 @@ interface ToolbarProps {
navCount: number
onNav: (dir: 1 | -1) => void
onExport: (fmt: ReportFormat) => void
- canExport: boolean
/** 仅看差异视图开关 */
onlyDiff: boolean
onOnlyDiffChange: (v: boolean) => void
@@ -33,7 +32,6 @@ export default function Toolbar({
navCount,
onNav,
onExport,
- canExport,
onlyDiff,
onOnlyDiffChange,
onSwap
@@ -115,11 +113,7 @@ export default function Toolbar({
-