Repository navigation
fix(web): support multiline highlight ranges in LightweightCodeHighlighter - #1699
brendan-kellam merged 3 commits into
Conversation
|
Note Currently processing new changes in this PR. This may take a few minutes, please wait... ⚙️ Run configuration
📒 Files selected for processing (1)
No actionable comments were generated in the recent review. 🎉 ℹ️ Recent review info⚙️ Run configurationConfiguration used: Organization UI Review profile: CHILL Plan: Advanced Run ID: 📒 Files selected for processing (2)
Included review availability: This review used your included allowance. Your plan provides up to 8 included reviews per hour; 7 remain after this review. Walkthrough
ChangesLine highlight mapping
Priority: ➖ Normal Estimated code review effort: 2 (Simple) | ~10 minutes Change: Bug fix · Severity of issue fixed: Medium Suggested reviewers: Merge Risk: ⚪ Minimal · up to The change corrects multiline highlighting and adds focused range-mapping tests. No merge-blocking issue is established; merge after normal checks pass. 🚥 Pre-merge checks | ✅ 5✅ Passed checks (5 passed)
✨ Finishing Touches🧪 Generate unit tests (beta)
Comment |
Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
Fixes #1698
Summary of Changes
Previously,
LightweightCodeHighlighterfiltered and mapped highlight ranges using a single-line check:This caused issues when a highlight range spanned multiple lines:
start.lineNumberandend.lineNumberwere completely dropped, resulting in no highlighting.from > to) or clipped ranges.Solution
Introduced
computeLineHighlightRanges(highlightRanges, lineNumber, lineLength)to correctly split multi-line 1-basedSourceRanges into 0-based character slices for each line.The new logic handles:
start.column - 1toline.length.0toline.length).0toend.column - 1.start.column - 1toend.column - 1.to <= from.Testing
Added comprehensive unit tests in:
packages/web/src/app/(app)/components/lightweightCodeHighlighter.test.tsThe tests cover:
Note
Low Risk
Search-result UI highlighting only; behavior is covered by new unit tests with no auth or data-path changes.
Overview
Fixes multi-line search/match highlights in
LightweightCodeHighlighterby replacing per-line logic that only considered start/end line numbers (and reused columns across lines) with exportedcomputeLineHighlightRanges, which maps 1-basedSourceRanges into per-line 0-based slices: partial highlight on the first and last lines, full-line highlight on lines in between, column clamping, and dropping empty ranges.Adds Vitest coverage for single-line, multi-line, clamping, invalid ranges, and multiple ranges on one line. CHANGELOG notes the fix for highlights not covering every line in a multi-line range.
Reviewed by Cursor Bugbot for commit 61d2be1. Bugbot is set up for automated code reviews on this repo. Configure here.
Summary by CodeRabbit