mirror of
https://github.com/stablyai/orca.git
synced 2026-09-22 16:02:32 +00:00
* Add per-file line counts to the source control sidebar Show +N/-N (green/red) next to each file in the Changes, Untracked, and Committed-on-branch sections so the magnitude of a change is visible at a glance. Counts are computed per staging area via `git diff --numstat`; untracked/new files count their full contents as additions and binary files show no count. Consolidate numstat parsing and binary-buffer detection into shared modules reused by the local status path, the SSH/relay path, and the existing branch-compare code. Include added/removed in the status-entry equality check so the sidebar doesn't re-render on unchanged polls. * fix: harden source control line counts --------- Co-authored-by: Neil <4138956+nwparker@users.noreply.github.com>
13 lines
336 B
TypeScript
13 lines
336 B
TypeScript
// A NUL byte in the first chunk is git's own heuristic for "this is binary".
|
|
const BINARY_SNIFF_BYTES = 8192
|
|
|
|
export function isBinaryBuffer(buffer: Buffer): boolean {
|
|
const len = Math.min(buffer.length, BINARY_SNIFF_BYTES)
|
|
for (let i = 0; i < len; i += 1) {
|
|
if (buffer[i] === 0) {
|
|
return true
|
|
}
|
|
}
|
|
return false
|
|
}
|