First pass on fixes
This commit is contained in:
parent
5826d89b97
commit
2f3be75fc7
269 changed files with 1593 additions and 2574 deletions
|
@ -1094,11 +1094,10 @@ impl BufferStore {
|
|||
.collect::<Vec<_>>()
|
||||
})?;
|
||||
for buffer_task in buffers {
|
||||
if let Some(buffer) = buffer_task.await.log_err() {
|
||||
if tx.send(buffer).await.is_err() {
|
||||
if let Some(buffer) = buffer_task.await.log_err()
|
||||
&& tx.send(buffer).await.is_err() {
|
||||
return anyhow::Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
anyhow::Ok(())
|
||||
|
@ -1173,12 +1172,11 @@ impl BufferStore {
|
|||
buffer_id: BufferId,
|
||||
handle: OpenLspBufferHandle,
|
||||
) {
|
||||
if let Some(shared_buffers) = self.shared_buffers.get_mut(&peer_id) {
|
||||
if let Some(buffer) = shared_buffers.get_mut(&buffer_id) {
|
||||
if let Some(shared_buffers) = self.shared_buffers.get_mut(&peer_id)
|
||||
&& let Some(buffer) = shared_buffers.get_mut(&buffer_id) {
|
||||
buffer.lsp_handle = Some(handle);
|
||||
return;
|
||||
}
|
||||
}
|
||||
debug_panic!("tried to register shared lsp handle, but buffer was not shared")
|
||||
}
|
||||
|
||||
|
@ -1388,15 +1386,14 @@ impl BufferStore {
|
|||
let peer_id = envelope.sender_id;
|
||||
let buffer_id = BufferId::new(envelope.payload.buffer_id)?;
|
||||
this.update(&mut cx, |this, cx| {
|
||||
if let Some(shared) = this.shared_buffers.get_mut(&peer_id) {
|
||||
if shared.remove(&buffer_id).is_some() {
|
||||
if let Some(shared) = this.shared_buffers.get_mut(&peer_id)
|
||||
&& shared.remove(&buffer_id).is_some() {
|
||||
cx.emit(BufferStoreEvent::SharedBufferClosed(peer_id, buffer_id));
|
||||
if shared.is_empty() {
|
||||
this.shared_buffers.remove(&peer_id);
|
||||
}
|
||||
return;
|
||||
}
|
||||
}
|
||||
debug_panic!(
|
||||
"peer_id {} closed buffer_id {} which was either not open or already closed",
|
||||
peer_id,
|
||||
|
|
|
@ -623,13 +623,12 @@ impl BreakpointStore {
|
|||
file_breakpoints.breakpoints.iter().filter_map({
|
||||
let range = range.clone();
|
||||
move |bp| {
|
||||
if let Some(range) = &range {
|
||||
if bp.position().cmp(&range.start, buffer_snapshot).is_lt()
|
||||
|| bp.position().cmp(&range.end, buffer_snapshot).is_gt()
|
||||
if let Some(range) = &range
|
||||
&& (bp.position().cmp(&range.start, buffer_snapshot).is_lt()
|
||||
|| bp.position().cmp(&range.end, buffer_snapshot).is_gt())
|
||||
{
|
||||
return None;
|
||||
}
|
||||
}
|
||||
let session_state = active_session_id
|
||||
.and_then(|id| bp.session_state.get(&id))
|
||||
.copied();
|
||||
|
|
|
@ -318,8 +318,7 @@ impl Iterator for MemoryIterator {
|
|||
return None;
|
||||
}
|
||||
if let Some((current_page_address, current_memory_chunk)) = self.current_known_page.as_mut()
|
||||
{
|
||||
if current_page_address.0 <= self.start {
|
||||
&& current_page_address.0 <= self.start {
|
||||
if let Some(next_cell) = current_memory_chunk.next() {
|
||||
self.start += 1;
|
||||
return Some(next_cell);
|
||||
|
@ -327,7 +326,6 @@ impl Iterator for MemoryIterator {
|
|||
self.current_known_page.take();
|
||||
}
|
||||
}
|
||||
}
|
||||
if !self.fetch_next_page() {
|
||||
self.start += 1;
|
||||
return Some(MemoryCell(None));
|
||||
|
|
|
@ -570,8 +570,8 @@ impl GitStore {
|
|||
cx: &mut Context<Self>,
|
||||
) -> Task<Result<Entity<BufferDiff>>> {
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
if let Some(diff_state) = self.diffs.get(&buffer_id) {
|
||||
if let Some(unstaged_diff) = diff_state
|
||||
if let Some(diff_state) = self.diffs.get(&buffer_id)
|
||||
&& let Some(unstaged_diff) = diff_state
|
||||
.read(cx)
|
||||
.unstaged_diff
|
||||
.as_ref()
|
||||
|
@ -587,7 +587,6 @@ impl GitStore {
|
|||
}
|
||||
return Task::ready(Ok(unstaged_diff));
|
||||
}
|
||||
}
|
||||
|
||||
let Some((repo, repo_path)) =
|
||||
self.repository_and_path_for_buffer_id(buffer.read(cx).remote_id(), cx)
|
||||
|
@ -627,8 +626,8 @@ impl GitStore {
|
|||
) -> Task<Result<Entity<BufferDiff>>> {
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
|
||||
if let Some(diff_state) = self.diffs.get(&buffer_id) {
|
||||
if let Some(uncommitted_diff) = diff_state
|
||||
if let Some(diff_state) = self.diffs.get(&buffer_id)
|
||||
&& let Some(uncommitted_diff) = diff_state
|
||||
.read(cx)
|
||||
.uncommitted_diff
|
||||
.as_ref()
|
||||
|
@ -644,7 +643,6 @@ impl GitStore {
|
|||
}
|
||||
return Task::ready(Ok(uncommitted_diff));
|
||||
}
|
||||
}
|
||||
|
||||
let Some((repo, repo_path)) =
|
||||
self.repository_and_path_for_buffer_id(buffer.read(cx).remote_id(), cx)
|
||||
|
@ -764,8 +762,8 @@ impl GitStore {
|
|||
log::debug!("open conflict set");
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
|
||||
if let Some(git_state) = self.diffs.get(&buffer_id) {
|
||||
if let Some(conflict_set) = git_state
|
||||
if let Some(git_state) = self.diffs.get(&buffer_id)
|
||||
&& let Some(conflict_set) = git_state
|
||||
.read(cx)
|
||||
.conflict_set
|
||||
.as_ref()
|
||||
|
@ -780,7 +778,6 @@ impl GitStore {
|
|||
|
||||
return conflict_set;
|
||||
}
|
||||
}
|
||||
|
||||
let is_unmerged = self
|
||||
.repository_and_path_for_buffer_id(buffer_id, cx)
|
||||
|
@ -1151,8 +1148,7 @@ impl GitStore {
|
|||
for (buffer_id, diff) in self.diffs.iter() {
|
||||
if let Some((buffer_repo, repo_path)) =
|
||||
self.repository_and_path_for_buffer_id(*buffer_id, cx)
|
||||
{
|
||||
if buffer_repo == repo {
|
||||
&& buffer_repo == repo {
|
||||
diff.update(cx, |diff, cx| {
|
||||
if let Some(conflict_set) = &diff.conflict_set {
|
||||
let conflict_status_changed =
|
||||
|
@ -1174,7 +1170,6 @@ impl GitStore {
|
|||
})
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
cx.emit(GitStoreEvent::RepositoryUpdated(
|
||||
id,
|
||||
|
@ -2231,14 +2226,13 @@ impl GitStore {
|
|||
) -> Result<()> {
|
||||
let buffer_id = BufferId::new(request.payload.buffer_id)?;
|
||||
this.update(&mut cx, |this, cx| {
|
||||
if let Some(diff_state) = this.diffs.get_mut(&buffer_id) {
|
||||
if let Some(buffer) = this.buffer_store.read(cx).get(buffer_id) {
|
||||
if let Some(diff_state) = this.diffs.get_mut(&buffer_id)
|
||||
&& let Some(buffer) = this.buffer_store.read(cx).get(buffer_id) {
|
||||
let buffer = buffer.read(cx).text_snapshot();
|
||||
diff_state.update(cx, |diff_state, cx| {
|
||||
diff_state.handle_base_texts_updated(buffer, request.payload, cx);
|
||||
})
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -3533,15 +3527,14 @@ impl Repository {
|
|||
let Some(project_path) = self.repo_path_to_project_path(path, cx) else {
|
||||
continue;
|
||||
};
|
||||
if let Some(buffer) = buffer_store.get_by_path(&project_path) {
|
||||
if buffer
|
||||
if let Some(buffer) = buffer_store.get_by_path(&project_path)
|
||||
&& buffer
|
||||
.read(cx)
|
||||
.file()
|
||||
.map_or(false, |file| file.disk_state().exists())
|
||||
{
|
||||
save_futures.push(buffer_store.save_buffer(buffer, cx));
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -3600,15 +3593,14 @@ impl Repository {
|
|||
let Some(project_path) = self.repo_path_to_project_path(path, cx) else {
|
||||
continue;
|
||||
};
|
||||
if let Some(buffer) = buffer_store.get_by_path(&project_path) {
|
||||
if buffer
|
||||
if let Some(buffer) = buffer_store.get_by_path(&project_path)
|
||||
&& buffer
|
||||
.read(cx)
|
||||
.file()
|
||||
.map_or(false, |file| file.disk_state().exists())
|
||||
{
|
||||
save_futures.push(buffer_store.save_buffer(buffer, cx));
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
@ -4421,14 +4413,13 @@ impl Repository {
|
|||
}
|
||||
|
||||
if let Some(job) = jobs.pop_front() {
|
||||
if let Some(current_key) = &job.key {
|
||||
if jobs
|
||||
if let Some(current_key) = &job.key
|
||||
&& jobs
|
||||
.iter()
|
||||
.any(|other_job| other_job.key.as_ref() == Some(current_key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
(job.job)(state.clone(), cx).await;
|
||||
} else if let Some(job) = job_rx.next().await {
|
||||
jobs.push_back(job);
|
||||
|
@ -4459,14 +4450,13 @@ impl Repository {
|
|||
}
|
||||
|
||||
if let Some(job) = jobs.pop_front() {
|
||||
if let Some(current_key) = &job.key {
|
||||
if jobs
|
||||
if let Some(current_key) = &job.key
|
||||
&& jobs
|
||||
.iter()
|
||||
.any(|other_job| other_job.key.as_ref() == Some(current_key))
|
||||
{
|
||||
continue;
|
||||
}
|
||||
}
|
||||
(job.job)(state.clone(), cx).await;
|
||||
} else if let Some(job) = job_rx.next().await {
|
||||
jobs.push_back(job);
|
||||
|
@ -4589,11 +4579,10 @@ impl Repository {
|
|||
|
||||
for (repo_path, status) in &*statuses.entries {
|
||||
changed_paths.remove(repo_path);
|
||||
if cursor.seek_forward(&PathTarget::Path(repo_path), Bias::Left) {
|
||||
if cursor.item().is_some_and(|entry| entry.status == *status) {
|
||||
if cursor.seek_forward(&PathTarget::Path(repo_path), Bias::Left)
|
||||
&& cursor.item().is_some_and(|entry| entry.status == *status) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
changed_path_statuses.push(Edit::Insert(StatusEntry {
|
||||
repo_path: repo_path.clone(),
|
||||
|
|
|
@ -182,12 +182,11 @@ impl<'a> Iterator for ChildEntriesGitIter<'a> {
|
|||
type Item = GitEntryRef<'a>;
|
||||
|
||||
fn next(&mut self) -> Option<Self::Item> {
|
||||
if let Some(item) = self.traversal.entry() {
|
||||
if item.path.starts_with(self.parent_path) {
|
||||
if let Some(item) = self.traversal.entry()
|
||||
&& item.path.starts_with(self.parent_path) {
|
||||
self.traversal.advance_to_sibling();
|
||||
return Some(item);
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
}
|
||||
|
|
|
@ -2341,8 +2341,8 @@ impl LspCommand for GetCompletions {
|
|||
.zip(completion_edits)
|
||||
.map(|(mut lsp_completion, mut edit)| {
|
||||
LineEnding::normalize(&mut edit.new_text);
|
||||
if lsp_completion.data.is_none() {
|
||||
if let Some(default_data) = lsp_defaults
|
||||
if lsp_completion.data.is_none()
|
||||
&& let Some(default_data) = lsp_defaults
|
||||
.as_ref()
|
||||
.and_then(|item_defaults| item_defaults.data.clone())
|
||||
{
|
||||
|
@ -2350,7 +2350,6 @@ impl LspCommand for GetCompletions {
|
|||
// so we do not insert the defaults here, but `data` is needed for resolving, so this is an exception.
|
||||
lsp_completion.data = Some(default_data);
|
||||
}
|
||||
}
|
||||
CoreCompletion {
|
||||
replace_range: edit.replace_range,
|
||||
new_text: edit.new_text,
|
||||
|
@ -2623,11 +2622,10 @@ impl LspCommand for GetCodeActions {
|
|||
.filter_map(|entry| {
|
||||
let (lsp_action, resolved) = match entry {
|
||||
lsp::CodeActionOrCommand::CodeAction(lsp_action) => {
|
||||
if let Some(command) = lsp_action.command.as_ref() {
|
||||
if !available_commands.contains(&command.command) {
|
||||
if let Some(command) = lsp_action.command.as_ref()
|
||||
&& !available_commands.contains(&command.command) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
(LspAction::Action(Box::new(lsp_action)), false)
|
||||
}
|
||||
lsp::CodeActionOrCommand::Command(command) => {
|
||||
|
@ -2641,11 +2639,9 @@ impl LspCommand for GetCodeActions {
|
|||
|
||||
if let Some((requested_kinds, kind)) =
|
||||
requested_kinds_set.as_ref().zip(lsp_action.action_kind())
|
||||
{
|
||||
if !requested_kinds.contains(&kind) {
|
||||
&& !requested_kinds.contains(&kind) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
Some(CodeAction {
|
||||
server_id,
|
||||
|
|
|
@ -701,11 +701,9 @@ impl LocalLspStore {
|
|||
async move {
|
||||
this.update(&mut cx, |this, _| {
|
||||
if let Some(status) = this.language_server_statuses.get_mut(&server_id)
|
||||
{
|
||||
if let lsp::NumberOrString::String(token) = params.token {
|
||||
&& let lsp::NumberOrString::String(token) = params.token {
|
||||
status.progress_tokens.insert(token);
|
||||
}
|
||||
}
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
|
@ -1015,11 +1013,10 @@ impl LocalLspStore {
|
|||
}
|
||||
}
|
||||
LanguageServerState::Starting { startup, .. } => {
|
||||
if let Some(server) = startup.await {
|
||||
if let Some(shutdown) = server.shutdown() {
|
||||
if let Some(server) = startup.await
|
||||
&& let Some(shutdown) = server.shutdown() {
|
||||
shutdown.await;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -2384,16 +2381,14 @@ impl LocalLspStore {
|
|||
return None;
|
||||
}
|
||||
if !only_register_servers.is_empty() {
|
||||
if let Some(server_id) = server_node.server_id() {
|
||||
if !only_register_servers.contains(&LanguageServerSelector::Id(server_id)) {
|
||||
if let Some(server_id) = server_node.server_id()
|
||||
&& !only_register_servers.contains(&LanguageServerSelector::Id(server_id)) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
if let Some(name) = server_node.name() {
|
||||
if !only_register_servers.contains(&LanguageServerSelector::Name(name)) {
|
||||
if let Some(name) = server_node.name()
|
||||
&& !only_register_servers.contains(&LanguageServerSelector::Name(name)) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let server_id = server_node.server_id_or_init(|disposition| {
|
||||
|
@ -2410,11 +2405,10 @@ impl LocalLspStore {
|
|||
cx,
|
||||
);
|
||||
|
||||
if let Some(state) = self.language_servers.get(&server_id) {
|
||||
if let Ok(uri) = uri {
|
||||
if let Some(state) = self.language_servers.get(&server_id)
|
||||
&& let Ok(uri) = uri {
|
||||
state.add_workspace_folder(uri);
|
||||
};
|
||||
}
|
||||
server_id
|
||||
};
|
||||
|
||||
|
@ -3844,15 +3838,14 @@ impl LspStore {
|
|||
}
|
||||
BufferStoreEvent::BufferChangedFilePath { buffer, old_file } => {
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
if let Some(local) = self.as_local_mut() {
|
||||
if let Some(old_file) = File::from_dyn(old_file.as_ref()) {
|
||||
if let Some(local) = self.as_local_mut()
|
||||
&& let Some(old_file) = File::from_dyn(old_file.as_ref()) {
|
||||
local.reset_buffer(buffer, old_file, cx);
|
||||
|
||||
if local.registered_buffers.contains_key(&buffer_id) {
|
||||
local.unregister_old_buffer_from_language_servers(buffer, old_file, cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.detect_language_for_buffer(buffer, cx);
|
||||
if let Some(local) = self.as_local_mut() {
|
||||
|
@ -4201,15 +4194,13 @@ impl LspStore {
|
|||
if local
|
||||
.registered_buffers
|
||||
.contains_key(&buffer.read(cx).remote_id())
|
||||
{
|
||||
if let Some(file_url) =
|
||||
&& let Some(file_url) =
|
||||
file_path_to_lsp_url(&f.abs_path(cx)).log_err()
|
||||
{
|
||||
local.unregister_buffer_from_language_servers(
|
||||
&buffer, &file_url, cx,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4306,21 +4297,17 @@ impl LspStore {
|
|||
let buffer = buffer_entity.read(cx);
|
||||
let buffer_file = buffer.file().cloned();
|
||||
let buffer_id = buffer.remote_id();
|
||||
if let Some(local_store) = self.as_local_mut() {
|
||||
if local_store.registered_buffers.contains_key(&buffer_id) {
|
||||
if let Some(abs_path) =
|
||||
if let Some(local_store) = self.as_local_mut()
|
||||
&& local_store.registered_buffers.contains_key(&buffer_id)
|
||||
&& let Some(abs_path) =
|
||||
File::from_dyn(buffer_file.as_ref()).map(|file| file.abs_path(cx))
|
||||
{
|
||||
if let Some(file_url) = file_path_to_lsp_url(&abs_path).log_err() {
|
||||
&& let Some(file_url) = file_path_to_lsp_url(&abs_path).log_err() {
|
||||
local_store.unregister_buffer_from_language_servers(
|
||||
buffer_entity,
|
||||
&file_url,
|
||||
cx,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
buffer_entity.update(cx, |buffer, cx| {
|
||||
if buffer.language().map_or(true, |old_language| {
|
||||
!Arc::ptr_eq(old_language, &new_language)
|
||||
|
@ -4336,22 +4323,21 @@ impl LspStore {
|
|||
let worktree_id = if let Some(file) = buffer_file {
|
||||
let worktree = file.worktree.clone();
|
||||
|
||||
if let Some(local) = self.as_local_mut() {
|
||||
if local.registered_buffers.contains_key(&buffer_id) {
|
||||
if let Some(local) = self.as_local_mut()
|
||||
&& local.registered_buffers.contains_key(&buffer_id) {
|
||||
local.register_buffer_with_language_servers(
|
||||
buffer_entity,
|
||||
HashSet::default(),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
}
|
||||
Some(worktree.read(cx).id())
|
||||
} else {
|
||||
None
|
||||
};
|
||||
|
||||
if settings.prettier.allowed {
|
||||
if let Some(prettier_plugins) = prettier_store::prettier_plugins_for_language(&settings)
|
||||
if settings.prettier.allowed
|
||||
&& let Some(prettier_plugins) = prettier_store::prettier_plugins_for_language(&settings)
|
||||
{
|
||||
let prettier_store = self.as_local().map(|s| s.prettier_store.clone());
|
||||
if let Some(prettier_store) = prettier_store {
|
||||
|
@ -4364,7 +4350,6 @@ impl LspStore {
|
|||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cx.emit(LspStoreEvent::LanguageDetected {
|
||||
buffer: buffer_entity.clone(),
|
||||
|
@ -4381,8 +4366,8 @@ impl LspStore {
|
|||
}
|
||||
|
||||
pub(crate) fn send_diagnostic_summaries(&self, worktree: &mut Worktree) {
|
||||
if let Some((client, downstream_project_id)) = self.downstream_client.clone() {
|
||||
if let Some(diangostic_summaries) = self.diagnostic_summaries.get(&worktree.id()) {
|
||||
if let Some((client, downstream_project_id)) = self.downstream_client.clone()
|
||||
&& let Some(diangostic_summaries) = self.diagnostic_summaries.get(&worktree.id()) {
|
||||
let mut summaries =
|
||||
diangostic_summaries
|
||||
.into_iter()
|
||||
|
@ -4402,7 +4387,6 @@ impl LspStore {
|
|||
.log_err();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: remove MultiLspQuery: instead, the proto handler should pick appropriate server(s)
|
||||
|
@ -4730,11 +4714,10 @@ impl LspStore {
|
|||
&language.name(),
|
||||
cx,
|
||||
);
|
||||
if let Some(state) = local.language_servers.get(&server_id) {
|
||||
if let Ok(uri) = uri {
|
||||
if let Some(state) = local.language_servers.get(&server_id)
|
||||
&& let Ok(uri) = uri {
|
||||
state.add_workspace_folder(uri);
|
||||
};
|
||||
}
|
||||
server_id
|
||||
});
|
||||
|
||||
|
@ -4805,8 +4788,8 @@ impl LspStore {
|
|||
LocalLspStore::try_resolve_code_action(&lang_server, &mut action)
|
||||
.await
|
||||
.context("resolving a code action")?;
|
||||
if let Some(edit) = action.lsp_action.edit() {
|
||||
if edit.changes.is_some() || edit.document_changes.is_some() {
|
||||
if let Some(edit) = action.lsp_action.edit()
|
||||
&& (edit.changes.is_some() || edit.document_changes.is_some()) {
|
||||
return LocalLspStore::deserialize_workspace_edit(
|
||||
this.upgrade().context("no app present")?,
|
||||
edit.clone(),
|
||||
|
@ -4817,7 +4800,6 @@ impl LspStore {
|
|||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(command) = action.lsp_action.command() {
|
||||
let server_capabilities = lang_server.capabilities();
|
||||
|
@ -5736,8 +5718,8 @@ impl LspStore {
|
|||
let version_queried_for = buffer.read(cx).version();
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
|
||||
if let Some(cached_data) = self.lsp_code_lens.get(&buffer_id) {
|
||||
if !version_queried_for.changed_since(&cached_data.lens_for_version) {
|
||||
if let Some(cached_data) = self.lsp_code_lens.get(&buffer_id)
|
||||
&& !version_queried_for.changed_since(&cached_data.lens_for_version) {
|
||||
let has_different_servers = self.as_local().is_some_and(|local| {
|
||||
local
|
||||
.buffers_opened_in_servers
|
||||
|
@ -5751,14 +5733,12 @@ impl LspStore {
|
|||
.shared();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let lsp_data = self.lsp_code_lens.entry(buffer_id).or_default();
|
||||
if let Some((updating_for, running_update)) = &lsp_data.update {
|
||||
if !version_queried_for.changed_since(updating_for) {
|
||||
if let Some((updating_for, running_update)) = &lsp_data.update
|
||||
&& !version_queried_for.changed_since(updating_for) {
|
||||
return running_update.clone();
|
||||
}
|
||||
}
|
||||
let buffer = buffer.clone();
|
||||
let query_version_queried_for = version_queried_for.clone();
|
||||
let new_task = cx
|
||||
|
@ -6372,12 +6352,11 @@ impl LspStore {
|
|||
.old_replace_start
|
||||
.and_then(deserialize_anchor)
|
||||
.zip(response.old_replace_end.and_then(deserialize_anchor));
|
||||
if let Some((old_replace_start, old_replace_end)) = replace_range {
|
||||
if !response.new_text.is_empty() {
|
||||
if let Some((old_replace_start, old_replace_end)) = replace_range
|
||||
&& !response.new_text.is_empty() {
|
||||
completion.new_text = response.new_text;
|
||||
completion.replace_range = old_replace_start..old_replace_end;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
@ -6751,8 +6730,8 @@ impl LspStore {
|
|||
LspFetchStrategy::UseCache {
|
||||
known_cache_version,
|
||||
} => {
|
||||
if let Some(cached_data) = self.lsp_document_colors.get(&buffer_id) {
|
||||
if !version_queried_for.changed_since(&cached_data.colors_for_version) {
|
||||
if let Some(cached_data) = self.lsp_document_colors.get(&buffer_id)
|
||||
&& !version_queried_for.changed_since(&cached_data.colors_for_version) {
|
||||
let has_different_servers = self.as_local().is_some_and(|local| {
|
||||
local
|
||||
.buffers_opened_in_servers
|
||||
|
@ -6780,16 +6759,14 @@ impl LspStore {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let lsp_data = self.lsp_document_colors.entry(buffer_id).or_default();
|
||||
if let Some((updating_for, running_update)) = &lsp_data.colors_update {
|
||||
if !version_queried_for.changed_since(updating_for) {
|
||||
if let Some((updating_for, running_update)) = &lsp_data.colors_update
|
||||
&& !version_queried_for.changed_since(updating_for) {
|
||||
return Some(running_update.clone());
|
||||
}
|
||||
}
|
||||
let query_version_queried_for = version_queried_for.clone();
|
||||
let new_task = cx
|
||||
.spawn(async move |lsp_store, cx| {
|
||||
|
@ -8785,14 +8762,12 @@ impl LspStore {
|
|||
if summary.is_empty() {
|
||||
if let Some(worktree_summaries) =
|
||||
lsp_store.diagnostic_summaries.get_mut(&worktree_id)
|
||||
{
|
||||
if let Some(summaries) = worktree_summaries.get_mut(&path) {
|
||||
&& let Some(summaries) = worktree_summaries.get_mut(&path) {
|
||||
summaries.remove(&server_id);
|
||||
if summaries.is_empty() {
|
||||
worktree_summaries.remove(&path);
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
lsp_store
|
||||
.diagnostic_summaries
|
||||
|
@ -9491,11 +9466,10 @@ impl LspStore {
|
|||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if let Some(status) = self.language_server_statuses.get_mut(&language_server_id) {
|
||||
if let Some(work) = status.pending_work.remove(&token) {
|
||||
if !work.is_disk_based_diagnostics_progress {
|
||||
if let Some(work) = status.pending_work.remove(&token)
|
||||
&& !work.is_disk_based_diagnostics_progress {
|
||||
cx.emit(LspStoreEvent::RefreshInlayHints);
|
||||
}
|
||||
}
|
||||
cx.notify();
|
||||
}
|
||||
|
||||
|
@ -10288,11 +10262,10 @@ impl LspStore {
|
|||
None => None,
|
||||
};
|
||||
|
||||
if let Some(server) = server {
|
||||
if let Some(shutdown) = server.shutdown() {
|
||||
if let Some(server) = server
|
||||
&& let Some(shutdown) = server.shutdown() {
|
||||
shutdown.await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Returns a list of all of the worktrees which no longer have a language server and the root path
|
||||
|
@ -10565,8 +10538,8 @@ impl LspStore {
|
|||
for buffer in buffers {
|
||||
buffer.update(cx, |buffer, cx| {
|
||||
language_servers_to_stop.extend(local.language_server_ids_for_buffer(buffer, cx));
|
||||
if let Some(worktree_id) = buffer.file().map(|f| f.worktree_id(cx)) {
|
||||
if covered_worktrees.insert(worktree_id) {
|
||||
if let Some(worktree_id) = buffer.file().map(|f| f.worktree_id(cx))
|
||||
&& covered_worktrees.insert(worktree_id) {
|
||||
language_server_names_to_stop.retain(|name| {
|
||||
let old_ids_count = language_servers_to_stop.len();
|
||||
let all_language_servers_with_this_name = local
|
||||
|
@ -10577,7 +10550,6 @@ impl LspStore {
|
|||
old_ids_count == language_servers_to_stop.len()
|
||||
});
|
||||
}
|
||||
}
|
||||
});
|
||||
}
|
||||
for name in language_server_names_to_stop {
|
||||
|
@ -11081,11 +11053,10 @@ impl LspStore {
|
|||
if let Some((LanguageServerState::Running { server, .. }, status)) = server.zip(status)
|
||||
{
|
||||
for (token, progress) in &status.pending_work {
|
||||
if let Some(token_to_cancel) = token_to_cancel.as_ref() {
|
||||
if token != token_to_cancel {
|
||||
if let Some(token_to_cancel) = token_to_cancel.as_ref()
|
||||
&& token != token_to_cancel {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
if progress.is_cancellable {
|
||||
server
|
||||
.notify::<lsp::notification::WorkDoneProgressCancel>(
|
||||
|
@ -11191,8 +11162,7 @@ impl LspStore {
|
|||
for server_id in &language_server_ids {
|
||||
if let Some(LanguageServerState::Running { server, .. }) =
|
||||
local.language_servers.get(server_id)
|
||||
{
|
||||
if let Some(watched_paths) = local
|
||||
&& let Some(watched_paths) = local
|
||||
.language_server_watched_paths
|
||||
.get(server_id)
|
||||
.and_then(|paths| paths.worktree_paths.get(&worktree_id))
|
||||
|
@ -11224,7 +11194,6 @@ impl LspStore {
|
|||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (path, _, _) in changes {
|
||||
if let Some(file_name) = path.file_name().and_then(|file_name| file_name.to_str())
|
||||
|
|
|
@ -84,11 +84,10 @@ impl<Label: Ord + Clone> RootPathTrie<Label> {
|
|||
) {
|
||||
let mut current = self;
|
||||
for key in path.0.iter() {
|
||||
if !current.labels.is_empty() {
|
||||
if (callback)(¤t.worktree_relative_path, ¤t.labels).is_break() {
|
||||
if !current.labels.is_empty()
|
||||
&& (callback)(¤t.worktree_relative_path, ¤t.labels).is_break() {
|
||||
return;
|
||||
};
|
||||
}
|
||||
current = match current.children.get(key) {
|
||||
Some(child) => child,
|
||||
None => return,
|
||||
|
|
|
@ -590,8 +590,8 @@ impl PrettierStore {
|
|||
new_plugins.clear();
|
||||
}
|
||||
let mut needs_install = should_write_prettier_server_file(fs.as_ref()).await;
|
||||
if let Some(previous_installation_task) = previous_installation_task {
|
||||
if let Err(e) = previous_installation_task.await {
|
||||
if let Some(previous_installation_task) = previous_installation_task
|
||||
&& let Err(e) = previous_installation_task.await {
|
||||
log::error!("Failed to install default prettier: {e:#}");
|
||||
prettier_store.update(cx, |prettier_store, _| {
|
||||
if let PrettierInstallation::NotInstalled { attempts, not_installed_plugins, .. } = &mut prettier_store.default_prettier.prettier {
|
||||
|
@ -601,8 +601,7 @@ impl PrettierStore {
|
|||
needs_install = true;
|
||||
};
|
||||
})?;
|
||||
}
|
||||
};
|
||||
};
|
||||
if installation_attempt > prettier::FAIL_THRESHOLD {
|
||||
prettier_store.update(cx, |prettier_store, _| {
|
||||
if let PrettierInstallation::NotInstalled { installation_task, .. } = &mut prettier_store.default_prettier.prettier {
|
||||
|
@ -679,14 +678,13 @@ impl PrettierStore {
|
|||
) {
|
||||
let mut prettier_plugins_by_worktree = HashMap::default();
|
||||
for (worktree, language_settings) in language_formatters_to_check {
|
||||
if language_settings.prettier.allowed {
|
||||
if let Some(plugins) = prettier_plugins_for_language(&language_settings) {
|
||||
if language_settings.prettier.allowed
|
||||
&& let Some(plugins) = prettier_plugins_for_language(&language_settings) {
|
||||
prettier_plugins_by_worktree
|
||||
.entry(worktree)
|
||||
.or_insert_with(HashSet::default)
|
||||
.extend(plugins.iter().cloned());
|
||||
}
|
||||
}
|
||||
}
|
||||
for (worktree, prettier_plugins) in prettier_plugins_by_worktree {
|
||||
self.install_default_prettier(
|
||||
|
|
|
@ -489,8 +489,8 @@ impl CompletionSource {
|
|||
..
|
||||
} = self
|
||||
{
|
||||
if apply_defaults {
|
||||
if let Some(lsp_defaults) = lsp_defaults {
|
||||
if apply_defaults
|
||||
&& let Some(lsp_defaults) = lsp_defaults {
|
||||
let mut completion_with_defaults = *lsp_completion.clone();
|
||||
let default_commit_characters = lsp_defaults.commit_characters.as_ref();
|
||||
let default_edit_range = lsp_defaults.edit_range.as_ref();
|
||||
|
@ -550,7 +550,6 @@ impl CompletionSource {
|
|||
}
|
||||
return Some(Cow::Owned(completion_with_defaults));
|
||||
}
|
||||
}
|
||||
Some(Cow::Borrowed(lsp_completion))
|
||||
} else {
|
||||
None
|
||||
|
@ -2755,12 +2754,11 @@ impl Project {
|
|||
operations,
|
||||
}))
|
||||
})?;
|
||||
if let Some(request) = request {
|
||||
if request.await.is_err() && !is_local {
|
||||
if let Some(request) = request
|
||||
&& request.await.is_err() && !is_local {
|
||||
*needs_resync_with_host = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
@ -3939,11 +3937,9 @@ impl Project {
|
|||
if let Some(entry) = b
|
||||
.entry_id(cx)
|
||||
.and_then(|entry_id| worktree_store.entry_for_id(entry_id, cx))
|
||||
{
|
||||
if entry.is_ignored && !search_query.include_ignored() {
|
||||
&& entry.is_ignored && !search_query.include_ignored() {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
}
|
||||
true
|
||||
})
|
||||
|
@ -4151,12 +4147,11 @@ impl Project {
|
|||
) -> Task<Option<ResolvedPath>> {
|
||||
let mut candidates = vec![path.clone()];
|
||||
|
||||
if let Some(file) = buffer.read(cx).file() {
|
||||
if let Some(dir) = file.path().parent() {
|
||||
if let Some(file) = buffer.read(cx).file()
|
||||
&& let Some(dir) = file.path().parent() {
|
||||
let joined = dir.to_path_buf().join(path);
|
||||
candidates.push(joined);
|
||||
}
|
||||
}
|
||||
|
||||
let buffer_worktree_id = buffer.read(cx).file().map(|file| file.worktree_id(cx));
|
||||
let worktrees_with_ids: Vec<_> = self
|
||||
|
@ -4168,8 +4163,8 @@ impl Project {
|
|||
.collect();
|
||||
|
||||
cx.spawn(async move |_, cx| {
|
||||
if let Some(buffer_worktree_id) = buffer_worktree_id {
|
||||
if let Some((worktree, _)) = worktrees_with_ids
|
||||
if let Some(buffer_worktree_id) = buffer_worktree_id
|
||||
&& let Some((worktree, _)) = worktrees_with_ids
|
||||
.iter()
|
||||
.find(|(_, id)| *id == buffer_worktree_id)
|
||||
{
|
||||
|
@ -4180,7 +4175,6 @@ impl Project {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
for (worktree, id) in worktrees_with_ids {
|
||||
if Some(id) == buffer_worktree_id {
|
||||
continue;
|
||||
|
|
|
@ -155,17 +155,15 @@ impl SearchQuery {
|
|||
let initial_query = Arc::from(query.as_str());
|
||||
if whole_word {
|
||||
let mut word_query = String::new();
|
||||
if let Some(first) = query.get(0..1) {
|
||||
if WORD_MATCH_TEST.is_match(first).is_ok_and(|x| !x) {
|
||||
if let Some(first) = query.get(0..1)
|
||||
&& WORD_MATCH_TEST.is_match(first).is_ok_and(|x| !x) {
|
||||
word_query.push_str("\\b");
|
||||
}
|
||||
}
|
||||
word_query.push_str(&query);
|
||||
if let Some(last) = query.get(query.len() - 1..) {
|
||||
if WORD_MATCH_TEST.is_match(last).is_ok_and(|x| !x) {
|
||||
if let Some(last) = query.get(query.len() - 1..)
|
||||
&& WORD_MATCH_TEST.is_match(last).is_ok_and(|x| !x) {
|
||||
word_query.push_str("\\b");
|
||||
}
|
||||
}
|
||||
query = word_query
|
||||
}
|
||||
|
||||
|
|
|
@ -45,21 +45,18 @@ impl SearchHistory {
|
|||
}
|
||||
|
||||
pub fn add(&mut self, cursor: &mut SearchHistoryCursor, search_string: String) {
|
||||
if self.insertion_behavior == QueryInsertionBehavior::ReplacePreviousIfContains {
|
||||
if let Some(previously_searched) = self.history.back_mut() {
|
||||
if search_string.contains(previously_searched.as_str()) {
|
||||
if self.insertion_behavior == QueryInsertionBehavior::ReplacePreviousIfContains
|
||||
&& let Some(previously_searched) = self.history.back_mut()
|
||||
&& search_string.contains(previously_searched.as_str()) {
|
||||
*previously_searched = search_string;
|
||||
cursor.selection = Some(self.history.len() - 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(max_history_len) = self.max_history_len {
|
||||
if self.history.len() >= max_history_len {
|
||||
if let Some(max_history_len) = self.max_history_len
|
||||
&& self.history.len() >= max_history_len {
|
||||
self.history.pop_front();
|
||||
}
|
||||
}
|
||||
self.history.push_back(search_string);
|
||||
|
||||
cursor.selection = Some(self.history.len() - 1);
|
||||
|
|
|
@ -119,14 +119,13 @@ impl Project {
|
|||
};
|
||||
|
||||
let mut settings_location = None;
|
||||
if let Some(path) = path.as_ref() {
|
||||
if let Some((worktree, _)) = self.find_worktree(path, cx) {
|
||||
if let Some(path) = path.as_ref()
|
||||
&& let Some((worktree, _)) = self.find_worktree(path, cx) {
|
||||
settings_location = Some(SettingsLocation {
|
||||
worktree_id: worktree.read(cx).id(),
|
||||
path,
|
||||
});
|
||||
}
|
||||
}
|
||||
let venv = TerminalSettings::get(settings_location, cx)
|
||||
.detect_venv
|
||||
.clone();
|
||||
|
@ -151,14 +150,13 @@ impl Project {
|
|||
cx: &'a App,
|
||||
) -> &'a TerminalSettings {
|
||||
let mut settings_location = None;
|
||||
if let Some(path) = path.as_ref() {
|
||||
if let Some((worktree, _)) = self.find_worktree(path, cx) {
|
||||
if let Some(path) = path.as_ref()
|
||||
&& let Some((worktree, _)) = self.find_worktree(path, cx) {
|
||||
settings_location = Some(SettingsLocation {
|
||||
worktree_id: worktree.read(cx).id(),
|
||||
path,
|
||||
});
|
||||
}
|
||||
}
|
||||
TerminalSettings::get(settings_location, cx)
|
||||
}
|
||||
|
||||
|
@ -239,14 +237,13 @@ impl Project {
|
|||
let is_ssh_terminal = ssh_details.is_some();
|
||||
|
||||
let mut settings_location = None;
|
||||
if let Some(path) = path.as_ref() {
|
||||
if let Some((worktree, _)) = this.find_worktree(path, cx) {
|
||||
if let Some(path) = path.as_ref()
|
||||
&& let Some((worktree, _)) = this.find_worktree(path, cx) {
|
||||
settings_location = Some(SettingsLocation {
|
||||
worktree_id: worktree.read(cx).id(),
|
||||
path,
|
||||
});
|
||||
}
|
||||
}
|
||||
let settings = TerminalSettings::get(settings_location, cx).clone();
|
||||
|
||||
let (completion_tx, completion_rx) = bounded(1);
|
||||
|
@ -665,12 +662,11 @@ pub fn wrap_for_ssh(
|
|||
env_changes.push_str(&format!("{}={} ", k, v));
|
||||
}
|
||||
}
|
||||
if let Some(venv_directory) = venv_directory {
|
||||
if let Ok(str) = shlex::try_quote(venv_directory.to_string_lossy().as_ref()) {
|
||||
if let Some(venv_directory) = venv_directory
|
||||
&& let Ok(str) = shlex::try_quote(venv_directory.to_string_lossy().as_ref()) {
|
||||
let path = RemotePathBuf::new(PathBuf::from(str.to_string()), path_style).to_string();
|
||||
env_changes.push_str(&format!("PATH={}:$PATH ", path));
|
||||
}
|
||||
}
|
||||
|
||||
let commands = if let Some(path) = path {
|
||||
let path = RemotePathBuf::new(path.to_path_buf(), path_style).to_string();
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue