diff options
author | Blaž Hrastnik | 2021-07-29 09:43:20 +0000 |
---|---|---|
committer | GitHub | 2021-07-29 09:43:20 +0000 |
commit | 05d20e196f81c8b71c2aecaf46f5d443d6b6b582 (patch) | |
tree | 0642d43c12f16ac3c68c19602c64fdea8108cc97 /helix-core/src/syntax.rs | |
parent | 8a2fa692f26f5bff5861151f395304837f5d93ec (diff) | |
parent | e4d41d06e3b52863d35ce3703f78cc8e0807c504 (diff) |
Merge pull request #376 from cessen/great_line_ending_and_cursor_range_cleanup
The Great Line Ending & Cursor Range Cleanup
Diffstat (limited to 'helix-core/src/syntax.rs')
-rw-r--r-- | helix-core/src/syntax.rs | 18 |
1 files changed, 14 insertions, 4 deletions
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs index 14f36a0a..c8cb0557 100644 --- a/helix-core/src/syntax.rs +++ b/helix-core/src/syntax.rs @@ -1760,10 +1760,20 @@ impl<I: Iterator<Item = HighlightEvent>> Iterator for Merge<I> { self.next_event = self.iter.next(); Some(event) } - // can happen if deleting and cursor at EOF, and diagnostic reaches past the end - (None, Some((_, _))) => { - self.next_span = None; - None + // Can happen if cursor at EOF and/or diagnostic reaches past the end. + // We need to actually emit events for the cursor-at-EOF situation, + // even though the range is past the end of the text. This needs to be + // handled appropriately by the drawing code by not assuming that + // all `Source` events point to valid indices in the rope. + (None, Some((span, range))) => { + let event = HighlightStart(Highlight(*span)); + self.queue.push(HighlightEnd); + self.queue.push(Source { + start: range.start, + end: range.end, + }); + self.next_span = self.spans.next(); + Some(event) } (None, None) => None, e => unreachable!("{:?}", e), |