mirror of
https://github.com/zed-industries/zed.git
synced 2025-01-12 21:32:40 +00:00
Don't return error when definition, completions, etc. are unavailable
Co-Authored-By: Nathan Sobo <nathan@zed.dev>
This commit is contained in:
parent
3fc3e51a44
commit
763d57c94a
2 changed files with 21 additions and 24 deletions
|
@ -2297,7 +2297,7 @@ impl History {
|
||||||
T: IntoIterator<Item = (&'a ModelHandle<Buffer>, &'a language::Transaction)>,
|
T: IntoIterator<Item = (&'a ModelHandle<Buffer>, &'a language::Transaction)>,
|
||||||
{
|
{
|
||||||
assert_eq!(self.transaction_depth, 0);
|
assert_eq!(self.transaction_depth, 0);
|
||||||
self.undo_stack.push(Transaction {
|
let transaction = Transaction {
|
||||||
id: self.next_transaction_id.tick(),
|
id: self.next_transaction_id.tick(),
|
||||||
buffer_transactions: buffer_transactions
|
buffer_transactions: buffer_transactions
|
||||||
.into_iter()
|
.into_iter()
|
||||||
|
@ -2306,7 +2306,10 @@ impl History {
|
||||||
first_edit_at: now,
|
first_edit_at: now,
|
||||||
last_edit_at: now,
|
last_edit_at: now,
|
||||||
suppress_grouping: false,
|
suppress_grouping: false,
|
||||||
});
|
};
|
||||||
|
if !transaction.buffer_transactions.is_empty() {
|
||||||
|
self.undo_stack.push(transaction);
|
||||||
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
fn finalize_last_transaction(&mut self) {
|
fn finalize_last_transaction(&mut self) {
|
||||||
|
|
|
@ -1065,13 +1065,10 @@ impl Project {
|
||||||
{
|
{
|
||||||
lang_server = server.clone();
|
lang_server = server.clone();
|
||||||
} else {
|
} else {
|
||||||
return Task::ready(Err(anyhow!(
|
return Task::ready(Ok(Default::default()));
|
||||||
"buffer {} does not have a language server",
|
|
||||||
buffer.remote_id()
|
|
||||||
)));
|
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return Task::ready(Err(anyhow!("buffer does not have a language")));
|
return Task::ready(Ok(Default::default()));
|
||||||
}
|
}
|
||||||
|
|
||||||
local_buffers.push((buffer_handle, buffer_abs_path, lang_server));
|
local_buffers.push((buffer_handle, buffer_abs_path, lang_server));
|
||||||
|
@ -1079,10 +1076,7 @@ impl Project {
|
||||||
remote_buffers.get_or_insert(Vec::new()).push(buffer_handle);
|
remote_buffers.get_or_insert(Vec::new()).push(buffer_handle);
|
||||||
}
|
}
|
||||||
} else {
|
} else {
|
||||||
return Task::ready(Err(anyhow!(
|
return Task::ready(Ok(Default::default()));
|
||||||
"buffer {} does not belong to any worktree",
|
|
||||||
buffer.remote_id()
|
|
||||||
)));
|
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1163,7 +1157,7 @@ impl Project {
|
||||||
worktree = file.worktree.clone();
|
worktree = file.worktree.clone();
|
||||||
buffer_abs_path = file.as_local().map(|f| f.abs_path(cx));
|
buffer_abs_path = file.as_local().map(|f| f.abs_path(cx));
|
||||||
} else {
|
} else {
|
||||||
return Task::ready(Err(anyhow!("buffer does not belong to any worktree")));
|
return Task::ready(Ok(Default::default()));
|
||||||
};
|
};
|
||||||
|
|
||||||
let position = position.to_point_utf16(source_buffer);
|
let position = position.to_point_utf16(source_buffer);
|
||||||
|
@ -1180,10 +1174,10 @@ impl Project {
|
||||||
{
|
{
|
||||||
lang_server = server.clone();
|
lang_server = server.clone();
|
||||||
} else {
|
} else {
|
||||||
return Task::ready(Err(anyhow!("buffer does not have a language server")));
|
return Task::ready(Ok(Default::default()));
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return Task::ready(Err(anyhow!("buffer does not have a language")));
|
return Task::ready(Ok(Default::default()));
|
||||||
}
|
}
|
||||||
|
|
||||||
cx.spawn(|this, mut cx| async move {
|
cx.spawn(|this, mut cx| async move {
|
||||||
|
@ -1282,7 +1276,7 @@ impl Project {
|
||||||
})
|
})
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Task::ready(Err(anyhow!("project does not have a remote id")))
|
Task::ready(Ok(Default::default()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1302,7 +1296,7 @@ impl Project {
|
||||||
worktree = file.worktree.clone();
|
worktree = file.worktree.clone();
|
||||||
buffer_abs_path = file.as_local().map(|f| f.abs_path(cx));
|
buffer_abs_path = file.as_local().map(|f| f.abs_path(cx));
|
||||||
} else {
|
} else {
|
||||||
return Task::ready(Err(anyhow!("buffer does not belong to any worktree")));
|
return Task::ready(Ok(Default::default()));
|
||||||
};
|
};
|
||||||
|
|
||||||
let position = position.to_point_utf16(source_buffer);
|
let position = position.to_point_utf16(source_buffer);
|
||||||
|
@ -1313,7 +1307,7 @@ impl Project {
|
||||||
let lang_server = if let Some(server) = source_buffer.language_server().cloned() {
|
let lang_server = if let Some(server) = source_buffer.language_server().cloned() {
|
||||||
server
|
server
|
||||||
} else {
|
} else {
|
||||||
return Task::ready(Err(anyhow!("buffer does not have a language server")));
|
return Task::ready(Ok(Default::default()));
|
||||||
};
|
};
|
||||||
|
|
||||||
cx.spawn(|_, cx| async move {
|
cx.spawn(|_, cx| async move {
|
||||||
|
@ -1385,7 +1379,7 @@ impl Project {
|
||||||
.collect()
|
.collect()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Task::ready(Err(anyhow!("project does not have a remote id")))
|
Task::ready(Ok(Default::default()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1403,7 +1397,7 @@ impl Project {
|
||||||
let lang_server = if let Some(language_server) = buffer.language_server() {
|
let lang_server = if let Some(language_server) = buffer.language_server() {
|
||||||
language_server.clone()
|
language_server.clone()
|
||||||
} else {
|
} else {
|
||||||
return Task::ready(Ok(Default::default()));
|
return Task::ready(Err(anyhow!("buffer does not have a language server")));
|
||||||
};
|
};
|
||||||
|
|
||||||
cx.spawn(|_, mut cx| async move {
|
cx.spawn(|_, mut cx| async move {
|
||||||
|
@ -1478,7 +1472,7 @@ impl Project {
|
||||||
worktree = file.worktree.clone();
|
worktree = file.worktree.clone();
|
||||||
buffer_abs_path = file.as_local().map(|f| f.abs_path(cx));
|
buffer_abs_path = file.as_local().map(|f| f.abs_path(cx));
|
||||||
} else {
|
} else {
|
||||||
return Task::ready(Err(anyhow!("buffer does not belong to any worktree")));
|
return Task::ready(Ok(Default::default()));
|
||||||
};
|
};
|
||||||
|
|
||||||
let position = position.to_point_utf16(source_buffer);
|
let position = position.to_point_utf16(source_buffer);
|
||||||
|
@ -1496,10 +1490,10 @@ impl Project {
|
||||||
{
|
{
|
||||||
lang_server = server.clone();
|
lang_server = server.clone();
|
||||||
} else {
|
} else {
|
||||||
return Task::ready(Err(anyhow!("buffer does not have a language server")));
|
return Task::ready(Ok(Default::default()));
|
||||||
};
|
};
|
||||||
} else {
|
} else {
|
||||||
return Task::ready(Err(anyhow!("buffer does not have a language")));
|
return Task::ready(Ok(Default::default()));
|
||||||
}
|
}
|
||||||
|
|
||||||
cx.foreground().spawn(async move {
|
cx.foreground().spawn(async move {
|
||||||
|
@ -1556,7 +1550,7 @@ impl Project {
|
||||||
.collect()
|
.collect()
|
||||||
})
|
})
|
||||||
} else {
|
} else {
|
||||||
Task::ready(Err(anyhow!("project does not have a remote id")))
|
Task::ready(Ok(Default::default()))
|
||||||
}
|
}
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -1577,7 +1571,7 @@ impl Project {
|
||||||
let lang_server = if let Some(language_server) = buffer.language_server() {
|
let lang_server = if let Some(language_server) = buffer.language_server() {
|
||||||
language_server.clone()
|
language_server.clone()
|
||||||
} else {
|
} else {
|
||||||
return Task::ready(Ok(Default::default()));
|
return Task::ready(Err(anyhow!("buffer does not have a language server")));
|
||||||
};
|
};
|
||||||
let position = action.position.to_point_utf16(buffer).to_lsp_position();
|
let position = action.position.to_point_utf16(buffer).to_lsp_position();
|
||||||
let fs = self.fs.clone();
|
let fs = self.fs.clone();
|
||||||
|
|
Loading…
Reference in a new issue