Auto-fix clippy::collapsible_if violations (#36428)
Release Notes: - N/A
This commit is contained in:
parent
9e8ec72bd5
commit
8f567383e4
281 changed files with 6628 additions and 7089 deletions
|
@ -1094,10 +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() {
|
||||
return anyhow::Ok(());
|
||||
}
|
||||
if let Some(buffer) = buffer_task.await.log_err()
|
||||
&& tx.send(buffer).await.is_err()
|
||||
{
|
||||
return anyhow::Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -1173,11 +1173,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) {
|
||||
buffer.lsp_handle = Some(handle);
|
||||
return;
|
||||
}
|
||||
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,14 +1388,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() {
|
||||
cx.emit(BufferStoreEvent::SharedBufferClosed(peer_id, buffer_id));
|
||||
if shared.is_empty() {
|
||||
this.shared_buffers.remove(&peer_id);
|
||||
}
|
||||
return;
|
||||
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",
|
||||
|
|
|
@ -623,12 +623,11 @@ 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()
|
||||
{
|
||||
return None;
|
||||
}
|
||||
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))
|
||||
|
|
|
@ -318,14 +318,13 @@ impl Iterator for MemoryIterator {
|
|||
return None;
|
||||
}
|
||||
if let Some((current_page_address, current_memory_chunk)) = self.current_known_page.as_mut()
|
||||
&& current_page_address.0 <= self.start
|
||||
{
|
||||
if current_page_address.0 <= self.start {
|
||||
if let Some(next_cell) = current_memory_chunk.next() {
|
||||
self.start += 1;
|
||||
return Some(next_cell);
|
||||
} else {
|
||||
self.current_known_page.take();
|
||||
}
|
||||
if let Some(next_cell) = current_memory_chunk.next() {
|
||||
self.start += 1;
|
||||
return Some(next_cell);
|
||||
} else {
|
||||
self.current_known_page.take();
|
||||
}
|
||||
}
|
||||
if !self.fetch_next_page() {
|
||||
|
|
|
@ -570,23 +570,22 @@ 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()
|
||||
.and_then(|weak| weak.upgrade())
|
||||
{
|
||||
if let Some(task) =
|
||||
diff_state.update(cx, |diff_state, _| diff_state.wait_for_recalculation())
|
||||
{
|
||||
if let Some(task) =
|
||||
diff_state.update(cx, |diff_state, _| diff_state.wait_for_recalculation())
|
||||
{
|
||||
return cx.background_executor().spawn(async move {
|
||||
task.await;
|
||||
Ok(unstaged_diff)
|
||||
});
|
||||
}
|
||||
return Task::ready(Ok(unstaged_diff));
|
||||
return cx.background_executor().spawn(async move {
|
||||
task.await;
|
||||
Ok(unstaged_diff)
|
||||
});
|
||||
}
|
||||
return Task::ready(Ok(unstaged_diff));
|
||||
}
|
||||
|
||||
let Some((repo, repo_path)) =
|
||||
|
@ -627,23 +626,22 @@ 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()
|
||||
.and_then(|weak| weak.upgrade())
|
||||
{
|
||||
if let Some(task) =
|
||||
diff_state.update(cx, |diff_state, _| diff_state.wait_for_recalculation())
|
||||
{
|
||||
if let Some(task) =
|
||||
diff_state.update(cx, |diff_state, _| diff_state.wait_for_recalculation())
|
||||
{
|
||||
return cx.background_executor().spawn(async move {
|
||||
task.await;
|
||||
Ok(uncommitted_diff)
|
||||
});
|
||||
}
|
||||
return Task::ready(Ok(uncommitted_diff));
|
||||
return cx.background_executor().spawn(async move {
|
||||
task.await;
|
||||
Ok(uncommitted_diff)
|
||||
});
|
||||
}
|
||||
return Task::ready(Ok(uncommitted_diff));
|
||||
}
|
||||
|
||||
let Some((repo, repo_path)) =
|
||||
|
@ -764,22 +762,21 @@ 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()
|
||||
.and_then(|weak| weak.upgrade())
|
||||
{
|
||||
let conflict_set = conflict_set.clone();
|
||||
let buffer_snapshot = buffer.read(cx).text_snapshot();
|
||||
{
|
||||
let conflict_set = conflict_set.clone();
|
||||
let buffer_snapshot = buffer.read(cx).text_snapshot();
|
||||
|
||||
git_state.update(cx, |state, cx| {
|
||||
let _ = state.reparse_conflict_markers(buffer_snapshot, cx);
|
||||
});
|
||||
git_state.update(cx, |state, cx| {
|
||||
let _ = state.reparse_conflict_markers(buffer_snapshot, cx);
|
||||
});
|
||||
|
||||
return conflict_set;
|
||||
}
|
||||
return conflict_set;
|
||||
}
|
||||
|
||||
let is_unmerged = self
|
||||
|
@ -1151,29 +1148,26 @@ 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)
|
||||
&& buffer_repo == repo
|
||||
{
|
||||
if buffer_repo == repo {
|
||||
diff.update(cx, |diff, cx| {
|
||||
if let Some(conflict_set) = &diff.conflict_set {
|
||||
let conflict_status_changed =
|
||||
conflict_set.update(cx, |conflict_set, cx| {
|
||||
let has_conflict = repo_snapshot.has_conflict(&repo_path);
|
||||
conflict_set.set_has_conflict(has_conflict, cx)
|
||||
})?;
|
||||
if conflict_status_changed {
|
||||
let buffer_store = self.buffer_store.read(cx);
|
||||
if let Some(buffer) = buffer_store.get(*buffer_id) {
|
||||
let _ = diff.reparse_conflict_markers(
|
||||
buffer.read(cx).text_snapshot(),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
diff.update(cx, |diff, cx| {
|
||||
if let Some(conflict_set) = &diff.conflict_set {
|
||||
let conflict_status_changed =
|
||||
conflict_set.update(cx, |conflict_set, cx| {
|
||||
let has_conflict = repo_snapshot.has_conflict(&repo_path);
|
||||
conflict_set.set_has_conflict(has_conflict, cx)
|
||||
})?;
|
||||
if conflict_status_changed {
|
||||
let buffer_store = self.buffer_store.read(cx);
|
||||
if let Some(buffer) = buffer_store.get(*buffer_id) {
|
||||
let _ = diff
|
||||
.reparse_conflict_markers(buffer.read(cx).text_snapshot(), cx);
|
||||
}
|
||||
}
|
||||
anyhow::Ok(())
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
anyhow::Ok(())
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
cx.emit(GitStoreEvent::RepositoryUpdated(
|
||||
|
@ -2231,13 +2225,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) {
|
||||
let buffer = buffer.read(cx).text_snapshot();
|
||||
diff_state.update(cx, |diff_state, cx| {
|
||||
diff_state.handle_base_texts_updated(buffer, request.payload, cx);
|
||||
})
|
||||
}
|
||||
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,14 +3527,13 @@ 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));
|
||||
}
|
||||
{
|
||||
save_futures.push(buffer_store.save_buffer(buffer, cx));
|
||||
}
|
||||
}
|
||||
})
|
||||
|
@ -3600,14 +3593,13 @@ 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));
|
||||
}
|
||||
{
|
||||
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,13 +4450,12 @@ 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;
|
||||
}
|
||||
{
|
||||
continue;
|
||||
}
|
||||
(job.job)(state.clone(), cx).await;
|
||||
} else if let Some(job) = job_rx.next().await {
|
||||
|
@ -4589,10 +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) {
|
||||
continue;
|
||||
}
|
||||
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 {
|
||||
|
|
|
@ -182,11 +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) {
|
||||
self.traversal.advance_to_sibling();
|
||||
return Some(item);
|
||||
}
|
||||
if let Some(item) = self.traversal.entry()
|
||||
&& item.path.starts_with(self.parent_path)
|
||||
{
|
||||
self.traversal.advance_to_sibling();
|
||||
return Some(item);
|
||||
}
|
||||
None
|
||||
}
|
||||
|
|
|
@ -2341,15 +2341,14 @@ 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())
|
||||
{
|
||||
// Servers (e.g. JDTLS) prefer unchanged completions, when resolving the items later,
|
||||
// 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);
|
||||
}
|
||||
{
|
||||
// Servers (e.g. JDTLS) prefer unchanged completions, when resolving the items later,
|
||||
// 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,
|
||||
|
@ -2623,10 +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) {
|
||||
return None;
|
||||
}
|
||||
if let Some(command) = lsp_action.command.as_ref()
|
||||
&& !available_commands.contains(&command.command)
|
||||
{
|
||||
return None;
|
||||
}
|
||||
(LspAction::Action(Box::new(lsp_action)), false)
|
||||
}
|
||||
|
@ -2641,10 +2640,9 @@ impl LspCommand for GetCodeActions {
|
|||
|
||||
if let Some((requested_kinds, kind)) =
|
||||
requested_kinds_set.as_ref().zip(lsp_action.action_kind())
|
||||
&& !requested_kinds.contains(&kind)
|
||||
{
|
||||
if !requested_kinds.contains(&kind) {
|
||||
return None;
|
||||
}
|
||||
return None;
|
||||
}
|
||||
|
||||
Some(CodeAction {
|
||||
|
|
|
@ -701,10 +701,9 @@ impl LocalLspStore {
|
|||
async move {
|
||||
this.update(&mut cx, |this, _| {
|
||||
if let Some(status) = this.language_server_statuses.get_mut(&server_id)
|
||||
&& let lsp::NumberOrString::String(token) = params.token
|
||||
{
|
||||
if let lsp::NumberOrString::String(token) = params.token {
|
||||
status.progress_tokens.insert(token);
|
||||
}
|
||||
status.progress_tokens.insert(token);
|
||||
}
|
||||
})?;
|
||||
|
||||
|
@ -1015,10 +1014,10 @@ impl LocalLspStore {
|
|||
}
|
||||
}
|
||||
LanguageServerState::Starting { startup, .. } => {
|
||||
if let Some(server) = startup.await {
|
||||
if let Some(shutdown) = server.shutdown() {
|
||||
shutdown.await;
|
||||
}
|
||||
if let Some(server) = startup.await
|
||||
&& let Some(shutdown) = server.shutdown()
|
||||
{
|
||||
shutdown.await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -2384,15 +2383,15 @@ 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)) {
|
||||
return None;
|
||||
}
|
||||
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)) {
|
||||
return None;
|
||||
}
|
||||
if let Some(name) = server_node.name()
|
||||
&& !only_register_servers.contains(&LanguageServerSelector::Name(name))
|
||||
{
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2410,11 +2409,11 @@ impl LocalLspStore {
|
|||
cx,
|
||||
);
|
||||
|
||||
if let Some(state) = self.language_servers.get(&server_id) {
|
||||
if let Ok(uri) = uri {
|
||||
state.add_workspace_folder(uri);
|
||||
};
|
||||
}
|
||||
if let Some(state) = self.language_servers.get(&server_id)
|
||||
&& let Ok(uri) = uri
|
||||
{
|
||||
state.add_workspace_folder(uri);
|
||||
};
|
||||
server_id
|
||||
};
|
||||
|
||||
|
@ -3844,13 +3843,13 @@ 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()) {
|
||||
local.reset_buffer(buffer, old_file, cx);
|
||||
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);
|
||||
}
|
||||
if local.registered_buffers.contains_key(&buffer_id) {
|
||||
local.unregister_old_buffer_from_language_servers(buffer, old_file, cx);
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4201,14 +4200,12 @@ 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,
|
||||
);
|
||||
}
|
||||
{
|
||||
local.unregister_buffer_from_language_servers(
|
||||
&buffer, &file_url, cx,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4306,20 +4303,13 @@ 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) =
|
||||
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() {
|
||||
local_store.unregister_buffer_from_language_servers(
|
||||
buffer_entity,
|
||||
&file_url,
|
||||
cx,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
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))
|
||||
&& 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| {
|
||||
|
@ -4336,33 +4326,28 @@ 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) {
|
||||
local.register_buffer_with_language_servers(
|
||||
buffer_entity,
|
||||
HashSet::default(),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
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)
|
||||
{
|
||||
let prettier_store = self.as_local().map(|s| s.prettier_store.clone());
|
||||
if let Some(prettier_store) = prettier_store {
|
||||
prettier_store.update(cx, |prettier_store, cx| {
|
||||
prettier_store.install_default_prettier(
|
||||
worktree_id,
|
||||
prettier_plugins.iter().map(|s| Arc::from(s.as_str())),
|
||||
cx,
|
||||
)
|
||||
})
|
||||
}
|
||||
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 {
|
||||
prettier_store.update(cx, |prettier_store, cx| {
|
||||
prettier_store.install_default_prettier(
|
||||
worktree_id,
|
||||
prettier_plugins.iter().map(|s| Arc::from(s.as_str())),
|
||||
cx,
|
||||
)
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -4381,26 +4366,25 @@ 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()) {
|
||||
let mut summaries =
|
||||
diangostic_summaries
|
||||
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()
|
||||
.flat_map(|(path, summaries)| {
|
||||
summaries
|
||||
.into_iter()
|
||||
.flat_map(|(path, summaries)| {
|
||||
summaries
|
||||
.into_iter()
|
||||
.map(|(server_id, summary)| summary.to_proto(*server_id, path))
|
||||
});
|
||||
if let Some(summary) = summaries.next() {
|
||||
client
|
||||
.send(proto::UpdateDiagnosticSummary {
|
||||
project_id: downstream_project_id,
|
||||
worktree_id: worktree.id().to_proto(),
|
||||
summary: Some(summary),
|
||||
more_summaries: summaries.collect(),
|
||||
})
|
||||
.log_err();
|
||||
}
|
||||
.map(|(server_id, summary)| summary.to_proto(*server_id, path))
|
||||
});
|
||||
if let Some(summary) = summaries.next() {
|
||||
client
|
||||
.send(proto::UpdateDiagnosticSummary {
|
||||
project_id: downstream_project_id,
|
||||
worktree_id: worktree.id().to_proto(),
|
||||
summary: Some(summary),
|
||||
more_summaries: summaries.collect(),
|
||||
})
|
||||
.log_err();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -4730,11 +4714,11 @@ impl LspStore {
|
|||
&language.name(),
|
||||
cx,
|
||||
);
|
||||
if let Some(state) = local.language_servers.get(&server_id) {
|
||||
if let Ok(uri) = uri {
|
||||
state.add_workspace_folder(uri);
|
||||
};
|
||||
}
|
||||
if let Some(state) = local.language_servers.get(&server_id)
|
||||
&& let Ok(uri) = uri
|
||||
{
|
||||
state.add_workspace_folder(uri);
|
||||
};
|
||||
server_id
|
||||
});
|
||||
|
||||
|
@ -4805,8 +4789,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 +4801,6 @@ impl LspStore {
|
|||
)
|
||||
.await;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(command) = action.lsp_action.command() {
|
||||
let server_capabilities = lang_server.capabilities();
|
||||
|
@ -5736,28 +5719,28 @@ 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) {
|
||||
let has_different_servers = self.as_local().is_some_and(|local| {
|
||||
local
|
||||
.buffers_opened_in_servers
|
||||
.get(&buffer_id)
|
||||
.cloned()
|
||||
.unwrap_or_default()
|
||||
!= cached_data.lens.keys().copied().collect()
|
||||
});
|
||||
if !has_different_servers {
|
||||
return Task::ready(Ok(cached_data.lens.values().flatten().cloned().collect()))
|
||||
.shared();
|
||||
}
|
||||
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
|
||||
.get(&buffer_id)
|
||||
.cloned()
|
||||
.unwrap_or_default()
|
||||
!= cached_data.lens.keys().copied().collect()
|
||||
});
|
||||
if !has_different_servers {
|
||||
return Task::ready(Ok(cached_data.lens.values().flatten().cloned().collect()))
|
||||
.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) {
|
||||
return running_update.clone();
|
||||
}
|
||||
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();
|
||||
|
@ -6372,11 +6355,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() {
|
||||
completion.new_text = response.new_text;
|
||||
completion.replace_range = old_replace_start..old_replace_end;
|
||||
}
|
||||
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,33 +6734,33 @@ 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) {
|
||||
let has_different_servers = self.as_local().is_some_and(|local| {
|
||||
local
|
||||
.buffers_opened_in_servers
|
||||
.get(&buffer_id)
|
||||
.cloned()
|
||||
.unwrap_or_default()
|
||||
!= cached_data.colors.keys().copied().collect()
|
||||
});
|
||||
if !has_different_servers {
|
||||
if Some(cached_data.cache_version) == known_cache_version {
|
||||
return None;
|
||||
} else {
|
||||
return Some(
|
||||
Task::ready(Ok(DocumentColors {
|
||||
colors: cached_data
|
||||
.colors
|
||||
.values()
|
||||
.flatten()
|
||||
.cloned()
|
||||
.collect(),
|
||||
cache_version: Some(cached_data.cache_version),
|
||||
}))
|
||||
.shared(),
|
||||
);
|
||||
}
|
||||
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
|
||||
.get(&buffer_id)
|
||||
.cloned()
|
||||
.unwrap_or_default()
|
||||
!= cached_data.colors.keys().copied().collect()
|
||||
});
|
||||
if !has_different_servers {
|
||||
if Some(cached_data.cache_version) == known_cache_version {
|
||||
return None;
|
||||
} else {
|
||||
return Some(
|
||||
Task::ready(Ok(DocumentColors {
|
||||
colors: cached_data
|
||||
.colors
|
||||
.values()
|
||||
.flatten()
|
||||
.cloned()
|
||||
.collect(),
|
||||
cache_version: Some(cached_data.cache_version),
|
||||
}))
|
||||
.shared(),
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -6785,10 +6768,10 @@ 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) {
|
||||
return Some(running_update.clone());
|
||||
}
|
||||
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
|
||||
|
@ -8785,12 +8768,11 @@ impl LspStore {
|
|||
if summary.is_empty() {
|
||||
if let Some(worktree_summaries) =
|
||||
lsp_store.diagnostic_summaries.get_mut(&worktree_id)
|
||||
&& let Some(summaries) = worktree_summaries.get_mut(&path)
|
||||
{
|
||||
if let Some(summaries) = worktree_summaries.get_mut(&path) {
|
||||
summaries.remove(&server_id);
|
||||
if summaries.is_empty() {
|
||||
worktree_summaries.remove(&path);
|
||||
}
|
||||
summaries.remove(&server_id);
|
||||
if summaries.is_empty() {
|
||||
worktree_summaries.remove(&path);
|
||||
}
|
||||
}
|
||||
} else {
|
||||
|
@ -9491,10 +9473,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 {
|
||||
cx.emit(LspStoreEvent::RefreshInlayHints);
|
||||
}
|
||||
if let Some(work) = status.pending_work.remove(&token)
|
||||
&& !work.is_disk_based_diagnostics_progress
|
||||
{
|
||||
cx.emit(LspStoreEvent::RefreshInlayHints);
|
||||
}
|
||||
cx.notify();
|
||||
}
|
||||
|
@ -10288,10 +10270,10 @@ impl LspStore {
|
|||
None => None,
|
||||
};
|
||||
|
||||
if let Some(server) = server {
|
||||
if let Some(shutdown) = server.shutdown() {
|
||||
shutdown.await;
|
||||
}
|
||||
if let Some(server) = server
|
||||
&& let Some(shutdown) = server.shutdown()
|
||||
{
|
||||
shutdown.await;
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -10565,18 +10547,18 @@ 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) {
|
||||
language_server_names_to_stop.retain(|name| {
|
||||
let old_ids_count = language_servers_to_stop.len();
|
||||
let all_language_servers_with_this_name = local
|
||||
.language_server_ids
|
||||
.iter()
|
||||
.filter_map(|(seed, state)| seed.name.eq(name).then(|| state.id));
|
||||
language_servers_to_stop.extend(all_language_servers_with_this_name);
|
||||
old_ids_count == language_servers_to_stop.len()
|
||||
});
|
||||
}
|
||||
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
|
||||
.language_server_ids
|
||||
.iter()
|
||||
.filter_map(|(seed, state)| seed.name.eq(name).then(|| state.id));
|
||||
language_servers_to_stop.extend(all_language_servers_with_this_name);
|
||||
old_ids_count == language_servers_to_stop.len()
|
||||
});
|
||||
}
|
||||
});
|
||||
}
|
||||
|
@ -11081,10 +11063,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 {
|
||||
continue;
|
||||
}
|
||||
if let Some(token_to_cancel) = token_to_cancel.as_ref()
|
||||
&& token != token_to_cancel
|
||||
{
|
||||
continue;
|
||||
}
|
||||
if progress.is_cancellable {
|
||||
server
|
||||
|
@ -11191,38 +11173,36 @@ 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))
|
||||
{
|
||||
let params = lsp::DidChangeWatchedFilesParams {
|
||||
changes: changes
|
||||
.iter()
|
||||
.filter_map(|(path, _, change)| {
|
||||
if !watched_paths.is_match(path) {
|
||||
return None;
|
||||
}
|
||||
let typ = match change {
|
||||
PathChange::Loaded => return None,
|
||||
PathChange::Added => lsp::FileChangeType::CREATED,
|
||||
PathChange::Removed => lsp::FileChangeType::DELETED,
|
||||
PathChange::Updated => lsp::FileChangeType::CHANGED,
|
||||
PathChange::AddedOrUpdated => lsp::FileChangeType::CHANGED,
|
||||
};
|
||||
Some(lsp::FileEvent {
|
||||
uri: lsp::Url::from_file_path(abs_path.join(path)).unwrap(),
|
||||
typ,
|
||||
})
|
||||
{
|
||||
let params = lsp::DidChangeWatchedFilesParams {
|
||||
changes: changes
|
||||
.iter()
|
||||
.filter_map(|(path, _, change)| {
|
||||
if !watched_paths.is_match(path) {
|
||||
return None;
|
||||
}
|
||||
let typ = match change {
|
||||
PathChange::Loaded => return None,
|
||||
PathChange::Added => lsp::FileChangeType::CREATED,
|
||||
PathChange::Removed => lsp::FileChangeType::DELETED,
|
||||
PathChange::Updated => lsp::FileChangeType::CHANGED,
|
||||
PathChange::AddedOrUpdated => lsp::FileChangeType::CHANGED,
|
||||
};
|
||||
Some(lsp::FileEvent {
|
||||
uri: lsp::Url::from_file_path(abs_path.join(path)).unwrap(),
|
||||
typ,
|
||||
})
|
||||
.collect(),
|
||||
};
|
||||
if !params.changes.is_empty() {
|
||||
server
|
||||
.notify::<lsp::notification::DidChangeWatchedFiles>(¶ms)
|
||||
.ok();
|
||||
}
|
||||
})
|
||||
.collect(),
|
||||
};
|
||||
if !params.changes.is_empty() {
|
||||
server
|
||||
.notify::<lsp::notification::DidChangeWatchedFiles>(¶ms)
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -84,11 +84,11 @@ 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() {
|
||||
return;
|
||||
};
|
||||
}
|
||||
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,13 +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) {
|
||||
prettier_plugins_by_worktree
|
||||
.entry(worktree)
|
||||
.or_insert_with(HashSet::default)
|
||||
.extend(plugins.iter().cloned());
|
||||
}
|
||||
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 {
|
||||
|
|
|
@ -489,67 +489,63 @@ impl CompletionSource {
|
|||
..
|
||||
} = self
|
||||
{
|
||||
if apply_defaults {
|
||||
if 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();
|
||||
let default_insert_text_format = lsp_defaults.insert_text_format.as_ref();
|
||||
let default_insert_text_mode = lsp_defaults.insert_text_mode.as_ref();
|
||||
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();
|
||||
let default_insert_text_format = lsp_defaults.insert_text_format.as_ref();
|
||||
let default_insert_text_mode = lsp_defaults.insert_text_mode.as_ref();
|
||||
|
||||
if default_commit_characters.is_some()
|
||||
|| default_edit_range.is_some()
|
||||
|| default_insert_text_format.is_some()
|
||||
|| default_insert_text_mode.is_some()
|
||||
if default_commit_characters.is_some()
|
||||
|| default_edit_range.is_some()
|
||||
|| default_insert_text_format.is_some()
|
||||
|| default_insert_text_mode.is_some()
|
||||
{
|
||||
if completion_with_defaults.commit_characters.is_none()
|
||||
&& default_commit_characters.is_some()
|
||||
{
|
||||
if completion_with_defaults.commit_characters.is_none()
|
||||
&& default_commit_characters.is_some()
|
||||
{
|
||||
completion_with_defaults.commit_characters =
|
||||
default_commit_characters.cloned()
|
||||
}
|
||||
if completion_with_defaults.text_edit.is_none() {
|
||||
match default_edit_range {
|
||||
Some(lsp::CompletionListItemDefaultsEditRange::Range(range)) => {
|
||||
completion_with_defaults.text_edit =
|
||||
Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit {
|
||||
range: *range,
|
||||
new_text: completion_with_defaults.label.clone(),
|
||||
}))
|
||||
}
|
||||
Some(
|
||||
lsp::CompletionListItemDefaultsEditRange::InsertAndReplace {
|
||||
insert,
|
||||
replace,
|
||||
},
|
||||
) => {
|
||||
completion_with_defaults.text_edit =
|
||||
Some(lsp::CompletionTextEdit::InsertAndReplace(
|
||||
lsp::InsertReplaceEdit {
|
||||
new_text: completion_with_defaults.label.clone(),
|
||||
insert: *insert,
|
||||
replace: *replace,
|
||||
},
|
||||
))
|
||||
}
|
||||
None => {}
|
||||
completion_with_defaults.commit_characters =
|
||||
default_commit_characters.cloned()
|
||||
}
|
||||
if completion_with_defaults.text_edit.is_none() {
|
||||
match default_edit_range {
|
||||
Some(lsp::CompletionListItemDefaultsEditRange::Range(range)) => {
|
||||
completion_with_defaults.text_edit =
|
||||
Some(lsp::CompletionTextEdit::Edit(lsp::TextEdit {
|
||||
range: *range,
|
||||
new_text: completion_with_defaults.label.clone(),
|
||||
}))
|
||||
}
|
||||
}
|
||||
if completion_with_defaults.insert_text_format.is_none()
|
||||
&& default_insert_text_format.is_some()
|
||||
{
|
||||
completion_with_defaults.insert_text_format =
|
||||
default_insert_text_format.cloned()
|
||||
}
|
||||
if completion_with_defaults.insert_text_mode.is_none()
|
||||
&& default_insert_text_mode.is_some()
|
||||
{
|
||||
completion_with_defaults.insert_text_mode =
|
||||
default_insert_text_mode.cloned()
|
||||
Some(lsp::CompletionListItemDefaultsEditRange::InsertAndReplace {
|
||||
insert,
|
||||
replace,
|
||||
}) => {
|
||||
completion_with_defaults.text_edit =
|
||||
Some(lsp::CompletionTextEdit::InsertAndReplace(
|
||||
lsp::InsertReplaceEdit {
|
||||
new_text: completion_with_defaults.label.clone(),
|
||||
insert: *insert,
|
||||
replace: *replace,
|
||||
},
|
||||
))
|
||||
}
|
||||
None => {}
|
||||
}
|
||||
}
|
||||
return Some(Cow::Owned(completion_with_defaults));
|
||||
if completion_with_defaults.insert_text_format.is_none()
|
||||
&& default_insert_text_format.is_some()
|
||||
{
|
||||
completion_with_defaults.insert_text_format =
|
||||
default_insert_text_format.cloned()
|
||||
}
|
||||
if completion_with_defaults.insert_text_mode.is_none()
|
||||
&& default_insert_text_mode.is_some()
|
||||
{
|
||||
completion_with_defaults.insert_text_mode =
|
||||
default_insert_text_mode.cloned()
|
||||
}
|
||||
}
|
||||
return Some(Cow::Owned(completion_with_defaults));
|
||||
}
|
||||
Some(Cow::Borrowed(lsp_completion))
|
||||
} else {
|
||||
|
@ -2755,11 +2751,12 @@ impl Project {
|
|||
operations,
|
||||
}))
|
||||
})?;
|
||||
if let Some(request) = request {
|
||||
if request.await.is_err() && !is_local {
|
||||
*needs_resync_with_host = true;
|
||||
break;
|
||||
}
|
||||
if let Some(request) = request
|
||||
&& request.await.is_err()
|
||||
&& !is_local
|
||||
{
|
||||
*needs_resync_with_host = true;
|
||||
break;
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
|
@ -3939,10 +3936,10 @@ impl Project {
|
|||
if let Some(entry) = b
|
||||
.entry_id(cx)
|
||||
.and_then(|entry_id| worktree_store.entry_for_id(entry_id, cx))
|
||||
&& entry.is_ignored
|
||||
&& !search_query.include_ignored()
|
||||
{
|
||||
if entry.is_ignored && !search_query.include_ignored() {
|
||||
return false;
|
||||
}
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
|
@ -4151,11 +4148,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() {
|
||||
let joined = dir.to_path_buf().join(path);
|
||||
candidates.push(joined);
|
||||
}
|
||||
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));
|
||||
|
@ -4168,16 +4165,14 @@ 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)
|
||||
{
|
||||
for candidate in candidates.iter() {
|
||||
if let Some(path) = Self::resolve_path_in_worktree(worktree, candidate, cx)
|
||||
{
|
||||
return Some(path);
|
||||
}
|
||||
{
|
||||
for candidate in candidates.iter() {
|
||||
if let Some(path) = Self::resolve_path_in_worktree(worktree, candidate, cx) {
|
||||
return Some(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -155,16 +155,16 @@ 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) {
|
||||
word_query.push_str("\\b");
|
||||
}
|
||||
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) {
|
||||
word_query.push_str("\\b");
|
||||
}
|
||||
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,20 +45,19 @@ 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()) {
|
||||
*previously_searched = search_string;
|
||||
cursor.selection = Some(self.history.len() - 1);
|
||||
return;
|
||||
}
|
||||
}
|
||||
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 {
|
||||
self.history.pop_front();
|
||||
}
|
||||
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);
|
||||
|
||||
|
|
|
@ -119,13 +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) {
|
||||
settings_location = Some(SettingsLocation {
|
||||
worktree_id: worktree.read(cx).id(),
|
||||
path,
|
||||
});
|
||||
}
|
||||
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
|
||||
|
@ -151,13 +151,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) {
|
||||
settings_location = Some(SettingsLocation {
|
||||
worktree_id: worktree.read(cx).id(),
|
||||
path,
|
||||
});
|
||||
}
|
||||
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,13 +239,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) {
|
||||
settings_location = Some(SettingsLocation {
|
||||
worktree_id: worktree.read(cx).id(),
|
||||
path,
|
||||
});
|
||||
}
|
||||
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();
|
||||
|
||||
|
@ -665,11 +665,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()) {
|
||||
let path = RemotePathBuf::new(PathBuf::from(str.to_string()), path_style).to_string();
|
||||
env_changes.push_str(&format!("PATH={}:$PATH ", path));
|
||||
}
|
||||
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 {
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue