Skip to content

Fix code viewer editor when line numbers are enabled - #638

Merged
mckaragoz merged 1 commit into
CodeBeamOrg:devfrom
DamienBraillard:fix-code-editor-with-line-numbers
Aug 16, 2026
Merged

Fix code viewer editor when line numbers are enabled#638
mckaragoz merged 1 commit into
CodeBeamOrg:devfrom
DamienBraillard:fix-code-editor-with-line-numbers

Conversation

@DamienBraillard

Copy link
Copy Markdown
Contributor

When ShowLineNumbers and Editable are both set to true on the MudCodViewer, there is a shift between the caret and the shown highlighted content.

This is due to the fact that the <pre> overlay is shifted right by 3.8em and the underlying <textarea> is not. So there is effectively a shift of 3.8em between the caret and the shown highlighted content.

I encountered the issue in my project and it has also been reported in issue #628.

The fix adds a new style for the <textarea> and applies it dynamically when ShowLineNumbers is true (as it was already done for the <pre>)

The 4th doc sample example has also been updated to allow enabling line numbers when in edit mode.

When `ShowLineNumbers` and `Editable` are both set to `true` on the `MudCodViewer`, there is a shift between the caret and the shown highlighted content.
This is due to the fact that the `<pre>` overlay is shifted right by `3.8em` and the underlying `<textarea>` is not. So there is effectively a shift of 3.8em between the caret and the shown highlighted content.
I encountered the issue in my project and it has also been reported in issue CodeBeamOrg#628.
The fix adds a new style for the `<textarea>` and applies it dynamically when `ShowLineNumbers` is `true` (as it was already done for the `<pre>`)
The 4th doc sample example has also been updated to allow enabling line numbers when in edit mode.
@DamienBraillard
DamienBraillardforce-pushed the fix-code-editor-with-line-numbers branch from b3b1ca6 to 3b2a5f0CompareAugust 14, 2026 13:38
@codecov

codecovBot commented Aug 16, 2026

Copy link
Copy Markdown

Codecov Report

✅ All modified and coverable lines are covered by tests.
✅ Project coverage is 65.32%. Comparing base (b750a06) to head (3b2a5f0).

Additional details and impacted files
@@ Coverage Diff @@## dev #638 +/- ##
==========================================
- Coverage 65.34% 65.32% -0.02% 
==========================================
Files 111 111 Lines 8354 8361 +7 Branches 1474 1474 ==========================================
+ Hits 5459 5462 +3 - Misses 2389 2393 +4 
Partials 506 506 

☔ View full report in Codecov by Harness.
📢 Have feedback on the report? Share it here.

🚀 New features to boost your workflow:
  • ❄️ Test Analytics: Detect flaky tests, report on failures, and find test suite problems.
  • 📦 JS Bundle Analysis: Save yourself from yourself by tracking and limiting bundle sizes in JS merges.

@mckaragoz
mckaragoz merged commit e5a58e5 into CodeBeamOrg:devAug 16, 2026
3 checks passed
@mckaragoz

Copy link
Copy Markdown
Contributor

Thanks 🥇

@DamienBraillard
DamienBraillard deleted the fix-code-editor-with-line-numbers branch August 17, 2026 08:21
Sign up for freeto 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

@DamienBraillard@mckaragoz