Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

tasks: Filter out run indicators outside of excerpt bounds instead of using saturating_sub (#11634)

Piotr Osiewiczb3dc31d7c9d2
diff --git a/crates/multi_buffer/src/multi_buffer.rs b/crates/multi_buffer/src/multi_buffer.rs
index 70343beb5e8..ab2ff89141b 100644
--- a/crates/multi_buffer/src/multi_buffer.rs
+++ b/crates/multi_buffer/src/multi_buffer.rs
@@ -3182,16 +3182,24 @@ impl MultiBufferSnapshot {
excerpt
.buffer
.runnable_ranges(excerpt.range.context.clone())
- .map(move |mut runnable| {
+ .filter_map(move |mut runnable| {
// Re-base onto the excerpts coordinates in the multibuffer
- runnable.run_range.start = excerpt_offset
- + runnable
- .run_range
- .start
- .saturating_sub(excerpt_buffer_start);
- runnable.run_range.end = excerpt_offset
- + runnable.run_range.end.saturating_sub(excerpt_buffer_start);
- runnable
+ //
+ // The node matching our runnables query might partially overlap with
+ // the provided range. If the run indicator is outside of excerpt bounds, do not actually show it.
+ if runnable.run_range.start < excerpt_buffer_start {
+ return None;
+ }
+ if language::ToPoint::to_point(&runnable.run_range.end, &excerpt.buffer).row
+ > excerpt.max_buffer_row
+ {
+ return None;
+ }
+ runnable.run_range.start =
+ excerpt_offset + runnable.run_range.start - excerpt_buffer_start;
+ runnable.run_range.end =
+ excerpt_offset + runnable.run_range.end - excerpt_buffer_start;
+ Some(runnable)
})
.skip_while(move |runnable| runnable.run_range.end < range.start)
.take_while(move |runnable| runnable.run_range.start < range.end)