Skip to content

fix(desktop): add visual gap between line number columns in inline diff#1019

Merged
Kitenite merged 2 commits into
mainfrom
kiet/super-273-visual-gap-merged-changes
Jan 28, 2026
Merged

fix(desktop): add visual gap between line number columns in inline diff#1019
Kitenite merged 2 commits into
mainfrom
kiet/super-273-visual-gap-merged-changes

Conversation

@Kitenite
Copy link
Copy Markdown
Collaborator

@Kitenite Kitenite commented Jan 28, 2026

Summary

  • Add dynamic calculation of lineNumbersMinChars based on file content
  • Calculates the digits needed for the max line count and adds 1 for visual spacing
  • Creates a gap between original and modified line number columns in inline diff view

Test plan

  • Open a diff in inline view mode
  • Verify there's visible spacing between the two line number columns
  • Test with files of varying sizes (10 lines, 100 lines, 1000+ lines)

Summary by CodeRabbit

  • New Features

    • Enhanced diff viewer with improved line number column width that automatically adjusts based on the number of lines in the file being reviewed.
  • Tests

    • Added comprehensive test coverage for line number formatting calculations across various file sizes.

✏️ Tip: You can customize this high-level summary in your review settings.

Dynamically calculate lineNumbersMinChars based on max line count plus 1
to create visual separation between original and modified line numbers.
@coderabbitai
Copy link
Copy Markdown
Contributor

coderabbitai Bot commented Jan 28, 2026

Caution

Review failed

The pull request is closed.

📝 Walkthrough

Walkthrough

This PR introduces a utility function getLineNumbersMinChars that dynamically computes the minimum character width required for line numbers in a Monaco diff editor based on the larger of the original and modified content's line counts. The function is integrated into DiffViewer.tsx and comprehensively tested.

Changes

Cohort / File(s) Summary
New Utility Function and Tests
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ChangesContent/components/DiffViewer/utils/getLineNumbersMinChars.ts, getLineNumbersMinChars.test.ts, index.ts
Added getLineNumbersMinChars function that calculates minimum character width for line numbers by determining the digit length of the max line count between original and modified content. Includes comprehensive test coverage for single-line, multi-line (1–9, 10–99, 100–999, 1000+ lines), and edge cases. Re-exported from utils/index.ts.
DiffViewer Integration
apps/desktop/src/renderer/screens/main/components/WorkspaceView/ChangesContent/components/DiffViewer/DiffViewer.tsx
Imported getLineNumbersMinChars and passed its computed value as the lineNumbersMinChars option to the Monaco DIFF editor, enabling dynamic line-number width calculation.

Estimated code review effort

🎯 2 (Simple) | ⏱️ ~12 minutes

Possibly related PRs

Poem

🐰 Counting lines with care so neat,
Line numbers get a perfect fit,
Monaco now knows just the width,
No truncation, no excess—a match!

✨ Finishing touches
  • 📝 Generate docstrings

Thanks for using CodeRabbit! It's free for OSS, and your support helps us grow. If you like it, consider giving us a shout-out.

❤️ Share

Comment @coderabbitai help to get the list of available commands and usage tips.

- Simplify algorithm using String().length instead of Math.log10
- Extract to dedicated utils folder with co-located tests
- Add comprehensive test coverage for edge cases
@Kitenite Kitenite merged commit 015331a into main Jan 28, 2026
4 checks passed
@github-actions
Copy link
Copy Markdown
Contributor

🧹 Preview Cleanup Complete

The following preview resources have been cleaned up:

  • ⚠️ Neon database branch
  • ⚠️ Electric Fly.io app

Thank you for your contribution! 🎉

@Kitenite Kitenite deleted the kiet/super-273-visual-gap-merged-changes branch January 28, 2026 06:55
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