mirror of
https://github.com/zed-industries/zed.git
synced 2026-05-30 20:24:08 +00:00
editor: Prevent panic in lsp_symbols_at_cursor with diff hunks handling (#51077)
Fixes ZED-5M9 No test as I couldn't quite reproduce this, as the cause is mostly a guess Release Notes: - Fixed a panic in `lsp_symbols_at_cursor` when dealing with diff hunks
This commit is contained in:
parent
8762b7f503
commit
3f2ddcbca3
3 changed files with 21 additions and 16 deletions
|
|
@ -212,18 +212,10 @@ pub fn init(client: Arc<Client>, cx: &mut App) {
|
|||
}
|
||||
|
||||
pub fn check(_: &Check, window: &mut Window, cx: &mut App) {
|
||||
if let Some(message) = option_env!("ZED_UPDATE_EXPLANATION") {
|
||||
drop(window.prompt(
|
||||
gpui::PromptLevel::Info,
|
||||
"Zed was installed via a package manager.",
|
||||
Some(message),
|
||||
&["Ok"],
|
||||
cx,
|
||||
));
|
||||
return;
|
||||
}
|
||||
|
||||
if let Ok(message) = env::var("ZED_UPDATE_EXPLANATION") {
|
||||
if let Some(message) = option_env!("ZED_UPDATE_EXPLANATION")
|
||||
.map(ToOwned::to_owned)
|
||||
.or_else(|| env::var("ZED_UPDATE_EXPLANATION").ok())
|
||||
{
|
||||
drop(window.prompt(
|
||||
gpui::PromptLevel::Info,
|
||||
"Zed was installed via a package manager.",
|
||||
|
|
|
|||
|
|
@ -77,6 +77,9 @@ impl Editor {
|
|||
let excerpt = multi_buffer_snapshot.excerpt_containing(cursor..cursor)?;
|
||||
let excerpt_id = excerpt.id();
|
||||
let buffer_id = excerpt.buffer_id();
|
||||
if Some(buffer_id) != cursor.text_anchor.buffer_id {
|
||||
return None;
|
||||
}
|
||||
let buffer = self.buffer.read(cx).buffer(buffer_id)?;
|
||||
let buffer_snapshot = buffer.read(cx).snapshot();
|
||||
let cursor_text_anchor = cursor.text_anchor;
|
||||
|
|
|
|||
|
|
@ -693,16 +693,21 @@ impl<'a> Cursor<'a> {
|
|||
}
|
||||
|
||||
pub fn seek_forward(&mut self, end_offset: usize) {
|
||||
debug_assert!(end_offset >= self.offset);
|
||||
assert!(
|
||||
end_offset >= self.offset,
|
||||
"cannot seek backward from {} to {}",
|
||||
self.offset,
|
||||
end_offset
|
||||
);
|
||||
|
||||
self.chunks.seek_forward(&end_offset, Bias::Right);
|
||||
self.offset = end_offset;
|
||||
}
|
||||
|
||||
pub fn slice(&mut self, end_offset: usize) -> Rope {
|
||||
debug_assert!(
|
||||
assert!(
|
||||
end_offset >= self.offset,
|
||||
"cannot slice backwards from {} to {}",
|
||||
"cannot slice backward from {} to {}",
|
||||
self.offset,
|
||||
end_offset
|
||||
);
|
||||
|
|
@ -730,7 +735,12 @@ impl<'a> Cursor<'a> {
|
|||
}
|
||||
|
||||
pub fn summary<D: TextDimension>(&mut self, end_offset: usize) -> D {
|
||||
debug_assert!(end_offset >= self.offset);
|
||||
assert!(
|
||||
end_offset >= self.offset,
|
||||
"cannot summarize backward from {} to {}",
|
||||
self.offset,
|
||||
end_offset
|
||||
);
|
||||
|
||||
let mut summary = D::zero(());
|
||||
if let Some(start_chunk) = self.chunks.item() {
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue