Skip to content

Add Ctrl+MouseWheel zoom for monospace font in compare view - #31

Merged
svenbuild merged 4 commits into
svenbuild:mainfrom
ElektroStudios:feature/ctrl-wheel-code-zoom
Nov 19, 2026
Merged

svenbuild merged 4 commits into
svenbuild:mainfrom
ElektroStudios:feature/ctrl-wheel-code-zoom

Conversation

@ElektroStudios

@ElektroStudios ElektroStudios commented Nov 19, 2026 •

Copy link
Copy Markdown
Contributor

Summary

  • Added Ctrl + MouseWheel zoom support in the Compare screen to adjust the Monospace font size (codeFontSize) in 1px increments within the existing min/max bounds (MIN_CODE_FONT_SIZE..MAX_CODE_FONT_SIZE).
  • Scoped the shortcut strictly to diff, document editor, and merge conflict panels (.compare-viewer, .workspace-editor, .merge-conflict-viewer) so scrolling elsewhere or over UI chrome does not change the interface font or trigger zoom.
  • Reused the existing setCodeFontSize handler in App.svelte so changes persist to session settings automatically and prevent native Chromium page zoom.
  • Added Vitest unit tests in src/lib/app/code-font-zoom.test.ts.

Validation

  • npm run check
  • npm test
  • npm run electron:package

Notes

I have no experience with TypeScript, Svelte, or Electron, so I delegated the code implementation to an AI assistant and verified the behavior locally on Windows. Please review carefully for any idiomatic improvements or edge cases I might have missed.

- Add a focused wheel-zoom helper (src/lib/app/code-font-zoom.ts) scoped exclusively to diff, editor, and merge conflict panels (.compare-viewer, .workspace-editor, .merge-conflict-viewer).
- Wire a non-passive wheel listener in CompareScreen to adjust appearanceSettings.codeFontSize by 1px per wheel step via the existing setCodeFontSize handler while preventing native Electron page zoom.
- Leave interface font size and all non-code panels untouched.
- Add unit tests in src/lib/app/code-font-zoom.test.ts covering target detection, zoom direction, min/max clamping, and ignored modifier/target cases.
Pache Sven added 3 commits November 19, 2026 17:42
Each Ctrl+wheel event changed the font by 1px, so touchpad pinch gestures,
which send many tiny deltas, raced through the whole range and re-rendered
the diff on every event. Deltas now add up to one step per mouse notch,
clamping is left to the existing font size setter, and the listener uses a
nonpassive event directive instead of manual mount wiring.
Ctrl+wheel past the minimum or maximum re-rendered the whole diff and
scheduled a session save on every notch.
@svenbuild
svenbuild merged commit 09c25d7 into svenbuild:main Nov 19, 2026
@svenbuild

Copy link
Copy Markdown
Owner

Thanks, merged! Changes I pushed on top before merging:

  • One mouse wheel notch is now exactly one step. Touchpad pinch sends many tiny Ctrl+wheel deltas; before, each one changed the size by 1px and re-rendered the diff, so a pinch raced through the whole range. Small deltas now add up (with remainder) before a step.
  • Clamping is left to the existing setCodeFontSize, which now skips updates that do not change the size, so zooming past the limit no longer re-renders the diff.
  • The listener uses on:wheel|nonpassive instead of manual mount wiring.

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.

2 participants