Skip to content

fix(diagnostics): preserve wrapped source text - #291

Merged
fcoury-oai merged 1 commit into
mainfrom
fcoury/diagnostic-wrap-overwrite
Aug 21, 2026
Merged

fcoury-oai merged 1 commit into
mainfrom
fcoury/diagnostic-wrap-overwrite

Conversation

@fcoury-oai

Copy link
Copy Markdown
Collaborator

Why

When an indented source line wrapped, inline diagnostics calculated their position without the continuation row's virtual break indentation. The diagnostic therefore started too far left and overwrote visible source text. Nearly full continuation rows could also display a diagnostic where no safe space remained.

What changed

  • Include LineSegment::visual_offset when calculating the inline diagnostic's end-of-line anchor in src/editor/rendering.rs.
  • Preserve the existing clipping behavior so diagnostics that no longer fit are hidden instead of painted over source text.
  • Add rendering regressions for a diagnostic that fits after a wrapped continuation and a continuation with insufficient remaining space.

How to Test

  1. Run cargo run -- and open a source file containing a deeply indented line long enough to wrap, with an LSP diagnostic on that line. Confirm the wrapped source suffix remains completely visible and the diagnostic begins after the source text.
  2. Extend the wrapped continuation until it nearly reaches the right window edge. Confirm the diagnostic disappears rather than overwriting source characters, and the following source line remains intact.
  3. Run cargo test -p red --lib wrapped_diagnostic; expect both new wrapped-diagnostic rendering regressions to pass.
  4. Run cargo test -p red --lib break_indent; expect the existing continuation indentation, tab expansion, disabled-indent, and selection-highlighting coverage to remain green.

Also verified all 2,058 editor unit tests and cargo clippy --all-targets --all-features -- -D warnings.

@fcoury-oai
fcoury-oai merged commit cb99f13 into main Aug 21, 2026
10 checks passed
@fcoury-oai
fcoury-oai deleted the fcoury/diagnostic-wrap-overwrite branch August 21, 2026 19:06
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