aboutsummaryrefslogtreecommitdiff
path: root/helix-core/src/syntax.rs
diff options
context:
space:
mode:
authorNathan Vegdahl2021-07-02 06:36:09 +0000
committerNathan Vegdahl2021-07-02 06:36:09 +0000
commit22dca3b111513f4dc0852acf0bfb0229a8661904 (patch)
tree214add658560426d12d94ccb71929050fb720487 /helix-core/src/syntax.rs
parent230248bbc3e453bab339cb865990c3fa2f518311 (diff)
Allow last line in file to lack a line break character.
Diffstat (limited to 'helix-core/src/syntax.rs')
-rw-r--r--helix-core/src/syntax.rs18
1 files changed, 14 insertions, 4 deletions
diff --git a/helix-core/src/syntax.rs b/helix-core/src/syntax.rs
index 9dbb2c03..d4379a8e 100644
--- a/helix-core/src/syntax.rs
+++ b/helix-core/src/syntax.rs
@@ -1758,10 +1758,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),