@@ -388,6 +388,8 @@ impl EditorView {
388388 spans.pop();
389389 }
390390 HighlightEvent::Source { start, end } => {
391+ let is_trailing_cursor = text.len_chars() < end;
392+
391393 // `unwrap_or_else` part is for off-the-end indices of
392394 // the rope, to allow cursor highlighting at the end
393395 // of the rope.
@@ -397,7 +399,7 @@ impl EditorView {
397399 .fold(text_style, |acc, span| acc.patch(theme.highlight(span.0)));
398400
399401 let space = if whitespace.render.space() == WhitespaceRenderValue::All
400− && text.len_chars() < end
402+ && !is_trailing_cursor
401403 {
402404 &space
403405 } else {