Fix run indicators jumping when buffer content changes. (#25507)
Co-authored-by: Anthony Eid <hello@anthonyeid.me> Release Notes: - Fix run indicators jumping when content changes --------- Co-authored-by: Anthony Eid <hello@anthonyeid.me>
This commit is contained in:
parent
63cfcc26fb
commit
7b277d2efd
3 changed files with 17 additions and 15 deletions
|
@ -524,7 +524,7 @@ impl ScrollbarMarkerState {
|
||||||
#[derive(Clone, Debug)]
|
#[derive(Clone, Debug)]
|
||||||
struct RunnableTasks {
|
struct RunnableTasks {
|
||||||
templates: Vec<(TaskSourceKind, TaskTemplate)>,
|
templates: Vec<(TaskSourceKind, TaskTemplate)>,
|
||||||
offset: MultiBufferOffset,
|
offset: multi_buffer::Anchor,
|
||||||
// We need the column at which the task context evaluation should take place (when we're spawning it via gutter).
|
// We need the column at which the task context evaluation should take place (when we're spawning it via gutter).
|
||||||
column: u32,
|
column: u32,
|
||||||
// Values of all named captures, including those starting with '_'
|
// Values of all named captures, including those starting with '_'
|
||||||
|
@ -551,8 +551,6 @@ struct ResolvedTasks {
|
||||||
templates: SmallVec<[(TaskSourceKind, ResolvedTask); 1]>,
|
templates: SmallVec<[(TaskSourceKind, ResolvedTask); 1]>,
|
||||||
position: Anchor,
|
position: Anchor,
|
||||||
}
|
}
|
||||||
#[derive(Copy, Clone, Debug)]
|
|
||||||
struct MultiBufferOffset(usize);
|
|
||||||
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
|
#[derive(Copy, Clone, Debug, PartialEq, PartialOrd)]
|
||||||
struct BufferOffset(usize);
|
struct BufferOffset(usize);
|
||||||
|
|
||||||
|
@ -10848,7 +10846,9 @@ impl Editor {
|
||||||
(runnable.buffer_id, row),
|
(runnable.buffer_id, row),
|
||||||
RunnableTasks {
|
RunnableTasks {
|
||||||
templates: tasks,
|
templates: tasks,
|
||||||
offset: MultiBufferOffset(runnable.run_range.start),
|
offset: snapshot
|
||||||
|
.buffer_snapshot
|
||||||
|
.anchor_before(runnable.run_range.start),
|
||||||
context_range,
|
context_range,
|
||||||
column: point.column,
|
column: point.column,
|
||||||
extra_variables: runnable.extra_captures,
|
extra_variables: runnable.extra_captures,
|
||||||
|
|
|
@ -15337,11 +15337,12 @@ async fn test_find_enclosing_node_with_task(cx: &mut TestAppContext) {
|
||||||
});
|
});
|
||||||
|
|
||||||
editor.update_in(cx, |editor, window, cx| {
|
editor.update_in(cx, |editor, window, cx| {
|
||||||
|
let snapshot = editor.buffer().read(cx).snapshot(cx);
|
||||||
editor.tasks.insert(
|
editor.tasks.insert(
|
||||||
(buffer.read(cx).remote_id(), 3),
|
(buffer.read(cx).remote_id(), 3),
|
||||||
RunnableTasks {
|
RunnableTasks {
|
||||||
templates: vec![],
|
templates: vec![],
|
||||||
offset: MultiBufferOffset(43),
|
offset: snapshot.anchor_before(43),
|
||||||
column: 0,
|
column: 0,
|
||||||
extra_variables: HashMap::default(),
|
extra_variables: HashMap::default(),
|
||||||
context_range: BufferOffset(43)..BufferOffset(85),
|
context_range: BufferOffset(43)..BufferOffset(85),
|
||||||
|
@ -15351,7 +15352,7 @@ async fn test_find_enclosing_node_with_task(cx: &mut TestAppContext) {
|
||||||
(buffer.read(cx).remote_id(), 8),
|
(buffer.read(cx).remote_id(), 8),
|
||||||
RunnableTasks {
|
RunnableTasks {
|
||||||
templates: vec![],
|
templates: vec![],
|
||||||
offset: MultiBufferOffset(86),
|
offset: snapshot.anchor_before(86),
|
||||||
column: 0,
|
column: 0,
|
||||||
extra_variables: HashMap::default(),
|
extra_variables: HashMap::default(),
|
||||||
context_range: BufferOffset(86)..BufferOffset(191),
|
context_range: BufferOffset(86)..BufferOffset(191),
|
||||||
|
|
|
@ -50,7 +50,7 @@ use language::{
|
||||||
use lsp::DiagnosticSeverity;
|
use lsp::DiagnosticSeverity;
|
||||||
use multi_buffer::{
|
use multi_buffer::{
|
||||||
Anchor, ExcerptId, ExcerptInfo, ExpandExcerptDirection, MultiBufferPoint, MultiBufferRow,
|
Anchor, ExcerptId, ExcerptInfo, ExpandExcerptDirection, MultiBufferPoint, MultiBufferRow,
|
||||||
RowInfo, ToOffset,
|
RowInfo,
|
||||||
};
|
};
|
||||||
use project::project_settings::{self, GitGutterSetting, ProjectSettings};
|
use project::project_settings::{self, GitGutterSetting, ProjectSettings};
|
||||||
use settings::Settings;
|
use settings::Settings;
|
||||||
|
@ -2062,21 +2062,22 @@ impl EditorElement {
|
||||||
None
|
None
|
||||||
};
|
};
|
||||||
|
|
||||||
let offset_range_start = snapshot
|
let offset_range_start =
|
||||||
.display_point_to_anchor(DisplayPoint::new(range.start, 0), Bias::Left)
|
snapshot.display_point_to_point(DisplayPoint::new(range.start, 0), Bias::Left);
|
||||||
.to_offset(&snapshot.buffer_snapshot);
|
|
||||||
let offset_range_end = snapshot
|
let offset_range_end =
|
||||||
.display_point_to_anchor(DisplayPoint::new(range.end, 0), Bias::Right)
|
snapshot.display_point_to_point(DisplayPoint::new(range.end, 0), Bias::Right);
|
||||||
.to_offset(&snapshot.buffer_snapshot);
|
|
||||||
|
|
||||||
editor
|
editor
|
||||||
.tasks
|
.tasks
|
||||||
.iter()
|
.iter()
|
||||||
.filter_map(|(_, tasks)| {
|
.filter_map(|(_, tasks)| {
|
||||||
if tasks.offset.0 < offset_range_start || tasks.offset.0 >= offset_range_end {
|
let multibuffer_point = tasks.offset.to_point(&snapshot.buffer_snapshot);
|
||||||
|
if multibuffer_point < offset_range_start
|
||||||
|
|| multibuffer_point > offset_range_end
|
||||||
|
{
|
||||||
return None;
|
return None;
|
||||||
}
|
}
|
||||||
let multibuffer_point = tasks.offset.0.to_point(&snapshot.buffer_snapshot);
|
|
||||||
let multibuffer_row = MultiBufferRow(multibuffer_point.row);
|
let multibuffer_row = MultiBufferRow(multibuffer_point.row);
|
||||||
let buffer_folded = snapshot
|
let buffer_folded = snapshot
|
||||||
.buffer_snapshot
|
.buffer_snapshot
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue