Skip to content

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

Open
DamienBraillard wants to merge 1 commit into
CodeBeamOrg:devfrom
DamienBraillard:fix-code-editor-with-line-numbers
Open

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

Conversation

@DamienBraillard

Copy link
Copy Markdown

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
DamienBraillard force-pushed the fix-code-editor-with-line-numbers branch from b3b1ca6 to 3b2a5f0 Compare August 14, 2026 13:38
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