🐛 fix(vscode): PR 统计条改全量口径与 Gitea 一致,已查看分母仍为可见文件数
This commit is contained in:
@@ -1,8 +1,8 @@
|
||||
/**
|
||||
* 「改动」tab(底部第四个):整个 PR 的改动以主从式呈现。
|
||||
*
|
||||
* - 左栏:统计条(共改 N 文件 · +X −Y · 已查看 M/N)+ 全 PR 文件树(目录树、状态徽标、
|
||||
* tests/ 过滤、已查看勾)。
|
||||
* - 左栏:统计条(共 N 文件 · +X −Y 为全量口径,含 tests/,与 Gitea 网页一致;已查看 M/N
|
||||
* 的分母是可见文件数)+ 文件树(目录树、状态徽标、tests/ 过滤、已查看勾)。
|
||||
* - 右栏:选中文件的内联 diff(git-diff-view,只渲染当前一个文件)。
|
||||
*
|
||||
* 自带 usePrFiles hook,直接经 lib/vscode 收发消息,不依赖上层回调。diff 左右两侧用
|
||||
@@ -87,16 +87,17 @@ export function PrFilesPanel({ issue }: PrFilesPanelProps) {
|
||||
// 路径 → 文件,选中时取 status/previousFilename。
|
||||
const fileByPath = useMemo(() => new Map(visibleFiles.map(f => [f.path, f])), [visibleFiles])
|
||||
|
||||
// total/±行数为全量口径(含 tests/,与 Gitea 网页一致);已查看的分母是可见文件数。
|
||||
const stats = useMemo(() => {
|
||||
let additions = 0
|
||||
let deletions = 0
|
||||
for (const f of visibleFiles) {
|
||||
for (const f of files) {
|
||||
additions += f.additions
|
||||
deletions += f.deletions
|
||||
}
|
||||
const confirmedCount = visibleFiles.filter(f => confirmedSet.has(f.path)).length
|
||||
return { total: visibleFiles.length, additions, deletions, confirmedCount }
|
||||
}, [visibleFiles, confirmedSet])
|
||||
return { total: files.length, additions, deletions, confirmedCount, visibleTotal: visibleFiles.length }
|
||||
}, [files, visibleFiles, confirmedSet])
|
||||
|
||||
const selectedFile = selectedPath ? fileByPath.get(selectedPath) : undefined
|
||||
|
||||
@@ -143,7 +144,7 @@ export function PrFilesPanel({ issue }: PrFilesPanelProps) {
|
||||
<span style={{ color: 'var(--vscode-gitDecoration-addedResourceForeground)' }}>{`+${stats.additions}`}</span>
|
||||
{' '}
|
||||
<span style={{ color: 'var(--vscode-gitDecoration-deletedResourceForeground)' }}>{`−${stats.deletions}`}</span>
|
||||
{` · 已查看 ${stats.confirmedCount}/${stats.total}`}
|
||||
{` · 已查看 ${stats.confirmedCount}/${stats.visibleTotal}`}
|
||||
</div>
|
||||
)}
|
||||
</div>
|
||||
|
||||
Reference in New Issue
Block a user