Skip to content

Commit

Permalink
Apply stylistic suggestions from code review
Browse files Browse the repository at this point in the history
Co-authored-by: Michael Davis <mcarsondavis@gmail.com>
  • Loading branch information
pascalkuthe and the-mikedavis authored Oct 3, 2022
1 parent 5b098c3 commit ed3cdd3
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
9 changes: 4 additions & 5 deletions helix-core/src/syntax/overlay.rs
Original file line number Diff line number Diff line change
Expand Up @@ -10,13 +10,13 @@ mod test;

/// Overlays multiple different highlights from `spans` onto the `HighlightEvent` stream `events`.
///
/// The [`Span`]s yielded by `spans` **must never overlap* or the iterator will produce incorrect results.
/// The [`Span`]s yielded by `spans` **must never overlap** or the iterator will produce incorrect results.
/// The [`Span`]s **must be sorted** in ascending order by their start.
/// If multiple [`Span`]s share the same start, the ordering is arbitrary.
///
/// Together these two properties mean that `spans` must prduce monotonically increasing [`Span`]s.
/// That means that the next span must always start after the last span ended:
/// `next_span.end <= span.start`
/// `span.end <= next_span.start`
pub fn monotonic_overlay<Events, Spans>(
events: Events,
spans: Spans,
Expand Down Expand Up @@ -192,7 +192,7 @@ where
if span.start < end {
// if the span starts inside the source,
// split off the start of the source that is not highlighted
// and emit this sourcespan first
// and emit this source span first
if start < span.start {
let partition_point = span.start;
let unhighlighted =
Expand Down Expand Up @@ -239,8 +239,7 @@ where
match replace(&mut self.next_event, self.events.next()) {
Some(event) => Some(event),
None => {
// Unfinished span at EOF is allowed to finish.
// Special case for cursor past EOF
// Unfinished span at EOF is allowed to finish.
let span = self.current_span.take()?;
self.queue.push(HighlightEnd);
self.queue.push(Source {
Expand Down
2 changes: 1 addition & 1 deletion helix-core/src/syntax/overlay/test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -15,7 +15,7 @@ fn overlay_long_hint() {
let highlights = overlapping_overlay(highlights, [0..4].into_iter(), Highlight(2));
let res: Vec<_> = highlights.collect();
assert_eq!(
&*res,
res,
&[
HighlightStart(Highlight(2)),
Source { start: 0, end: 2 },
Expand Down

0 comments on commit ed3cdd3

Please sign in to comment.