mirror of
https://github.com/zed-industries/zed.git
synced 2024-12-27 12:02:07 +03:00
Merge pull request #759 from zed-industries/breadcrumb-multibuffer-fix
Update breadcrumbs when multibuffers' excerpts change
This commit is contained in:
commit
ce547010d8
@ -16,6 +16,7 @@ use language::{
|
||||
Bias, Buffer, Diagnostic, DiagnosticEntry, DiagnosticSeverity, Point, Selection, SelectionGoal,
|
||||
};
|
||||
use project::{DiagnosticSummary, Project, ProjectPath};
|
||||
use settings::Settings;
|
||||
use std::{
|
||||
any::{Any, TypeId},
|
||||
cmp::Ordering,
|
||||
@ -26,7 +27,6 @@ use std::{
|
||||
};
|
||||
use util::TryFutureExt;
|
||||
use workspace::{ItemHandle as _, ItemNavHistory, Workspace};
|
||||
use settings::Settings;
|
||||
|
||||
action!(Deploy);
|
||||
|
||||
|
@ -788,7 +788,7 @@ impl MultiBuffer {
|
||||
old: edit_start..edit_start,
|
||||
new: edit_start..edit_end,
|
||||
}]);
|
||||
|
||||
cx.emit(Event::Edited);
|
||||
cx.notify();
|
||||
ids
|
||||
}
|
||||
@ -802,10 +802,12 @@ impl MultiBuffer {
|
||||
snapshot.trailing_excerpt_update_count += 1;
|
||||
snapshot.is_dirty = false;
|
||||
snapshot.has_conflict = false;
|
||||
|
||||
self.subscriptions.publish_mut([Edit {
|
||||
old: 0..prev_len,
|
||||
new: 0..0,
|
||||
}]);
|
||||
cx.emit(Event::Edited);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
@ -993,6 +995,7 @@ impl MultiBuffer {
|
||||
}
|
||||
|
||||
self.subscriptions.publish_mut(edits);
|
||||
cx.emit(Event::Edited);
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
@ -2928,7 +2931,7 @@ mod tests {
|
||||
use gpui::MutableAppContext;
|
||||
use language::{Buffer, Rope};
|
||||
use rand::prelude::*;
|
||||
use std::env;
|
||||
use std::{env, rc::Rc};
|
||||
use text::{Point, RandomCharIter};
|
||||
use util::test::sample_text;
|
||||
|
||||
@ -2985,6 +2988,15 @@ mod tests {
|
||||
let buffer_2 = cx.add_model(|cx| Buffer::new(0, sample_text(6, 6, 'g'), cx));
|
||||
let multibuffer = cx.add_model(|_| MultiBuffer::new(0));
|
||||
|
||||
let events = Rc::new(RefCell::new(Vec::<Event>::new()));
|
||||
multibuffer.update(cx, |_, cx| {
|
||||
let events = events.clone();
|
||||
cx.subscribe(&multibuffer, move |_, _, event, _| {
|
||||
events.borrow_mut().push(event.clone())
|
||||
})
|
||||
.detach();
|
||||
});
|
||||
|
||||
let subscription = multibuffer.update(cx, |multibuffer, cx| {
|
||||
let subscription = multibuffer.subscribe();
|
||||
multibuffer.push_excerpts(buffer_1.clone(), [Point::new(1, 2)..Point::new(2, 5)], cx);
|
||||
@ -3009,6 +3021,12 @@ mod tests {
|
||||
subscription
|
||||
});
|
||||
|
||||
// Adding excerpts emits an edited event.
|
||||
assert_eq!(
|
||||
events.borrow().as_slice(),
|
||||
&[Event::Edited, Event::Edited, Event::Edited]
|
||||
);
|
||||
|
||||
let snapshot = multibuffer.read(cx).snapshot(cx);
|
||||
assert_eq!(
|
||||
snapshot.text(),
|
||||
|
@ -1633,93 +1633,84 @@ impl Project {
|
||||
return;
|
||||
}
|
||||
};
|
||||
|
||||
match progress.value {
|
||||
lsp::ProgressParamsValue::WorkDone(progress) => match progress {
|
||||
lsp::WorkDoneProgress::Begin(_) => {
|
||||
let language_server_status =
|
||||
if let Some(status) = self.language_server_statuses.get_mut(&server_id) {
|
||||
status
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
|
||||
if Some(token.as_str()) == disk_based_diagnostics_progress_token {
|
||||
language_server_status.pending_diagnostic_updates += 1;
|
||||
if language_server_status.pending_diagnostic_updates == 1 {
|
||||
self.disk_based_diagnostics_started(cx);
|
||||
self.broadcast_language_server_update(
|
||||
server_id,
|
||||
proto::update_language_server::Variant::DiskBasedDiagnosticsUpdating(
|
||||
proto::LspDiskBasedDiagnosticsUpdating {},
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
self.on_lsp_work_start(server_id, token.clone(), cx);
|
||||
let progress = match progress.value {
|
||||
lsp::ProgressParamsValue::WorkDone(value) => value,
|
||||
};
|
||||
let language_server_status =
|
||||
if let Some(status) = self.language_server_statuses.get_mut(&server_id) {
|
||||
status
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
match progress {
|
||||
lsp::WorkDoneProgress::Begin(_) => {
|
||||
if Some(token.as_str()) == disk_based_diagnostics_progress_token {
|
||||
language_server_status.pending_diagnostic_updates += 1;
|
||||
if language_server_status.pending_diagnostic_updates == 1 {
|
||||
self.disk_based_diagnostics_started(cx);
|
||||
self.broadcast_language_server_update(
|
||||
server_id,
|
||||
proto::update_language_server::Variant::WorkStart(
|
||||
proto::LspWorkStart { token },
|
||||
proto::update_language_server::Variant::DiskBasedDiagnosticsUpdating(
|
||||
proto::LspDiskBasedDiagnosticsUpdating {},
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
self.on_lsp_work_start(server_id, token.clone(), cx);
|
||||
self.broadcast_language_server_update(
|
||||
server_id,
|
||||
proto::update_language_server::Variant::WorkStart(proto::LspWorkStart {
|
||||
token,
|
||||
}),
|
||||
);
|
||||
}
|
||||
lsp::WorkDoneProgress::Report(report) => {
|
||||
if Some(token.as_str()) != disk_based_diagnostics_progress_token {
|
||||
self.on_lsp_work_progress(
|
||||
server_id,
|
||||
token.clone(),
|
||||
LanguageServerProgress {
|
||||
message: report.message.clone(),
|
||||
percentage: report.percentage.map(|p| p as usize),
|
||||
last_update_at: Instant::now(),
|
||||
},
|
||||
cx,
|
||||
);
|
||||
self.broadcast_language_server_update(
|
||||
server_id,
|
||||
proto::update_language_server::Variant::WorkProgress(
|
||||
proto::LspWorkProgress {
|
||||
token,
|
||||
message: report.message,
|
||||
percentage: report.percentage.map(|p| p as u32),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
lsp::WorkDoneProgress::End(_) => {
|
||||
if Some(token.as_str()) == disk_based_diagnostics_progress_token {
|
||||
let language_server_status = if let Some(status) =
|
||||
self.language_server_statuses.get_mut(&server_id)
|
||||
{
|
||||
status
|
||||
} else {
|
||||
return;
|
||||
};
|
||||
|
||||
language_server_status.pending_diagnostic_updates -= 1;
|
||||
if language_server_status.pending_diagnostic_updates == 0 {
|
||||
self.disk_based_diagnostics_finished(cx);
|
||||
self.broadcast_language_server_update(
|
||||
server_id,
|
||||
proto::update_language_server::Variant::DiskBasedDiagnosticsUpdated(
|
||||
proto::LspDiskBasedDiagnosticsUpdated {},
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
self.on_lsp_work_end(server_id, token.clone(), cx);
|
||||
self.broadcast_language_server_update(
|
||||
server_id,
|
||||
proto::update_language_server::Variant::WorkEnd(proto::LspWorkEnd {
|
||||
}
|
||||
lsp::WorkDoneProgress::Report(report) => {
|
||||
if Some(token.as_str()) != disk_based_diagnostics_progress_token {
|
||||
self.on_lsp_work_progress(
|
||||
server_id,
|
||||
token.clone(),
|
||||
LanguageServerProgress {
|
||||
message: report.message.clone(),
|
||||
percentage: report.percentage.map(|p| p as usize),
|
||||
last_update_at: Instant::now(),
|
||||
},
|
||||
cx,
|
||||
);
|
||||
self.broadcast_language_server_update(
|
||||
server_id,
|
||||
proto::update_language_server::Variant::WorkProgress(
|
||||
proto::LspWorkProgress {
|
||||
token,
|
||||
}),
|
||||
message: report.message,
|
||||
percentage: report.percentage.map(|p| p as u32),
|
||||
},
|
||||
),
|
||||
);
|
||||
}
|
||||
}
|
||||
lsp::WorkDoneProgress::End(_) => {
|
||||
if Some(token.as_str()) == disk_based_diagnostics_progress_token {
|
||||
language_server_status.pending_diagnostic_updates -= 1;
|
||||
if language_server_status.pending_diagnostic_updates == 0 {
|
||||
self.disk_based_diagnostics_finished(cx);
|
||||
self.broadcast_language_server_update(
|
||||
server_id,
|
||||
proto::update_language_server::Variant::DiskBasedDiagnosticsUpdated(
|
||||
proto::LspDiskBasedDiagnosticsUpdated {},
|
||||
),
|
||||
);
|
||||
}
|
||||
} else {
|
||||
self.on_lsp_work_end(server_id, token.clone(), cx);
|
||||
self.broadcast_language_server_update(
|
||||
server_id,
|
||||
proto::update_language_server::Variant::WorkEnd(proto::LspWorkEnd {
|
||||
token,
|
||||
}),
|
||||
);
|
||||
}
|
||||
},
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user