Skip to content

chore(preview): delete six declarations nothing reads - #427

Merged
PathGao merged 1 commit into
masterfrom
chore/drop-dead-load-revision-map
Aug 3, 2026
Merged

chore(preview): delete six declarations nothing reads#427
PathGao merged 1 commit into
masterfrom
chore/drop-dead-load-revision-map

Conversation

@PathGao

@PathGao PathGao commented Aug 3, 2026

Copy link
Copy Markdown
Collaborator

MarkdownViewer.svelte declares six top-level bindings the file never mentions again. They read as live state, so anyone tracing how rendering or scroll sync works has to prove each one is inert before ruling it out.

declaration introduced occurrences in the introducing commit
let containerEl: HTMLElement b46a283 1
const renderDebounceMs = 50 b46a283 1
let renderTimeout: ReturnType<typeof setTimeout> | null b46a283 1
let caretEl: HTMLElement ef219cf 1
let caretAbsoluteTop = 0 ef219cf 1
const loadRevisionByTab = new Map<string, number>() 41de13b (#247) 4

Five were never used at all. One occurrence in the commit that introduces them means the declaration and nothing else. renderDebounceMs = 50 next to renderTimeout is the one most likely to mislead — together they describe a render debounce that does not exist anywhere in the file.

One is refactor residue. loadRevisionByTab had four occurrences when #247 added it here. bb8dbf3 (#274) extracted document loading into src/lib/sessions/documentSession.svelte.ts, which carries its own map and all three call sites; the declaration here stayed behind, dropping to one occurrence. Two identically named maps in two files, one of them dead, is worse than either alone — a reader who greps the name finds both.

How "unreferenced" was established

Grep alone is not sufficient in a Svelte component: bind:this={containerEl} in the template is a real use, and a name can be reached from the markup without appearing in the script block. So:

  1. Counted occurrences across the whole file, template included — each is exactly 1.
  2. Grepped src/ and scripts/ for each name outside this file — none.
  3. npm run check (438 files, 0 errors) and npm run build — the compiler resolving the template is the check that matters. A template reference to a deleted binding fails the build.

scripts/largeFileLoadRevision.test.ts pins the live map in documentSession.svelte.ts and is untouched.

Verification

npm run check   438 files, 0 errors, 0 warnings
npm test        546 / 546
npm run build   clean

Not covered

  • Only top-level let/const in this one file. Unused imports, unused function parameters, and dead code in other files were not swept — a wider sweep would be a different change with a different review surface.
  • caretEl/caretAbsoluteTop came in with split view and scroll syncing (ef219cf). They were dead on arrival, so removing them cannot change scroll sync, but it also does not tell you whether the caret-tracking they were meant for is missing on purpose. That question is left where it was.

🤖 Generated with Claude Code

@PathGao
PathGao force-pushed the chore/drop-dead-load-revision-map branch from 076205d to 072a366 Compare August 3, 2026 07:45
`MarkdownViewer.svelte` declares six top-level bindings that the file
never mentions again. They read as live state — a container element, a
render debounce and its timer handle, a per-tab load revision map, a
caret element and its measured offset — so anyone tracing how rendering
or scroll sync works has to prove each one is inert before ruling it
out.

Five were never used at all. `containerEl`, `renderTimeout` and
`renderDebounceMs` arrive in b46a283 and `caretEl`/`caretAbsoluteTop` in
ef219cf, each already at exactly one occurrence in the commit that adds
them: the declaration, and nothing else. `renderDebounceMs = 50` in
particular suggests a debounce that does not exist.

One is refactor residue. `loadRevisionByTab` had four occurrences when
41de13b (#247) added it here. bb8dbf3 (#274) moved document loading into
`documentSession.svelte.ts`, which carries its own map and the three
call sites; the declaration here stayed behind. Two identically named
maps in two files, one of them dead, is worse than either alone —
`scripts/largeFileLoadRevision.test.ts` pins the live one in
`documentSession.svelte.ts` and is unaffected.

Nothing else changes. `npm run check` and `npm run build` were the
check that matters: an unreferenced binding is only safe to remove if
the compiler agrees nothing reaches it, including through Svelte's
`bind:this`, which is why this is verified by a build rather than by
grep alone.

Co-Authored-By: Claude Opus 5 <noreply@anthropic.com>
@PathGao
PathGao force-pushed the chore/drop-dead-load-revision-map branch from 072a366 to 3ce2ae9 Compare August 3, 2026 07:46
@PathGao
PathGao merged commit d3fbb2a into master Aug 3, 2026
4 checks passed
@PathGao
PathGao deleted the chore/drop-dead-load-revision-map branch August 3, 2026 09:24
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant