Compare commits
10 commits
main
...
clippy-col
Author | SHA1 | Date | |
---|---|---|---|
![]() |
30f91777d4 | ||
![]() |
5b6b3f553e | ||
![]() |
f13ea62842 | ||
![]() |
253467c5e6 | ||
![]() |
33606e06e5 | ||
![]() |
bf577383a5 | ||
![]() |
b4ef6ec60b | ||
![]() |
3b801880a6 | ||
![]() |
2f3be75fc7 | ||
![]() |
5826d89b97 |
276 changed files with 1696 additions and 2684 deletions
|
@ -830,6 +830,7 @@ module_inception = { level = "deny" }
|
|||
question_mark = { level = "deny" }
|
||||
redundant_closure = { level = "deny" }
|
||||
declare_interior_mutable_const = { level = "deny" }
|
||||
collapsible_if = { level = "warn"}
|
||||
needless_borrow = { level = "warn"}
|
||||
# Individual rules that have violations in the codebase:
|
||||
type_complexity = "allow"
|
||||
|
|
|
@ -249,15 +249,14 @@ impl ToolCall {
|
|||
}
|
||||
|
||||
if let Some(raw_output) = raw_output {
|
||||
if self.content.is_empty() {
|
||||
if let Some(markdown) = markdown_for_raw_output(&raw_output, &language_registry, cx)
|
||||
if self.content.is_empty()
|
||||
&& let Some(markdown) = markdown_for_raw_output(&raw_output, &language_registry, cx)
|
||||
{
|
||||
self.content
|
||||
.push(ToolCallContent::ContentBlock(ContentBlock::Markdown {
|
||||
markdown,
|
||||
}));
|
||||
}
|
||||
}
|
||||
self.raw_output = Some(raw_output);
|
||||
}
|
||||
}
|
||||
|
@ -430,12 +429,11 @@ impl ContentBlock {
|
|||
language_registry: &Arc<LanguageRegistry>,
|
||||
cx: &mut App,
|
||||
) {
|
||||
if matches!(self, ContentBlock::Empty) {
|
||||
if let acp::ContentBlock::ResourceLink(resource_link) = block {
|
||||
if matches!(self, ContentBlock::Empty)
|
||||
&& let acp::ContentBlock::ResourceLink(resource_link) = block {
|
||||
*self = ContentBlock::ResourceLink { resource_link };
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let new_content = self.block_string_contents(block);
|
||||
|
||||
|
|
|
@ -614,11 +614,10 @@ impl ActionLog {
|
|||
false
|
||||
}
|
||||
});
|
||||
if tracked_buffer.unreviewed_edits.is_empty() {
|
||||
if let TrackedBufferStatus::Created { .. } = &mut tracked_buffer.status {
|
||||
if tracked_buffer.unreviewed_edits.is_empty()
|
||||
&& let TrackedBufferStatus::Created { .. } = &mut tracked_buffer.status {
|
||||
tracked_buffer.status = TrackedBufferStatus::Modified;
|
||||
}
|
||||
}
|
||||
tracked_buffer.schedule_diff_update(ChangeAuthor::User, cx);
|
||||
}
|
||||
}
|
||||
|
|
|
@ -458,8 +458,8 @@ impl ActivityIndicator {
|
|||
.map(|r| r.read(cx))
|
||||
.and_then(Repository::current_job);
|
||||
// Show any long-running git command
|
||||
if let Some(job_info) = current_job {
|
||||
if Instant::now() - job_info.start >= GIT_OPERATION_DELAY {
|
||||
if let Some(job_info) = current_job
|
||||
&& Instant::now() - job_info.start >= GIT_OPERATION_DELAY {
|
||||
return Some(Content {
|
||||
icon: Some(
|
||||
Icon::new(IconName::ArrowCircle)
|
||||
|
@ -478,7 +478,6 @@ impl ActivityIndicator {
|
|||
tooltip_message: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
// Show any language server installation info.
|
||||
let mut downloading = SmallVec::<[_; 3]>::new();
|
||||
|
@ -740,8 +739,7 @@ impl ActivityIndicator {
|
|||
|
||||
if let Some(extension_store) =
|
||||
ExtensionStore::try_global(cx).map(|extension_store| extension_store.read(cx))
|
||||
{
|
||||
if let Some(extension_id) = extension_store.outstanding_operations().keys().next() {
|
||||
&& let Some(extension_id) = extension_store.outstanding_operations().keys().next() {
|
||||
return Some(Content {
|
||||
icon: Some(
|
||||
Icon::new(IconName::Download)
|
||||
|
@ -755,7 +753,6 @@ impl ActivityIndicator {
|
|||
tooltip_message: None,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
|
|
@ -201,8 +201,8 @@ impl FileContextHandle {
|
|||
parse_status.changed().await.log_err();
|
||||
}
|
||||
|
||||
if let Ok(snapshot) = buffer.read_with(cx, |buffer, _| buffer.snapshot()) {
|
||||
if let Some(outline) = snapshot.outline(None) {
|
||||
if let Ok(snapshot) = buffer.read_with(cx, |buffer, _| buffer.snapshot())
|
||||
&& let Some(outline) = snapshot.outline(None) {
|
||||
let items = outline
|
||||
.items
|
||||
.into_iter()
|
||||
|
@ -220,7 +220,6 @@ impl FileContextHandle {
|
|||
return Some((context, vec![buffer]));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -338,12 +338,11 @@ impl ContextStore {
|
|||
image_task,
|
||||
context_id: self.next_context_id.post_inc(),
|
||||
});
|
||||
if self.has_context(&context) {
|
||||
if remove_if_exists {
|
||||
if self.has_context(&context)
|
||||
&& remove_if_exists {
|
||||
self.remove_context(&context, cx);
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
self.insert_context(context.clone(), cx);
|
||||
Some(context)
|
||||
|
|
|
@ -1967,11 +1967,9 @@ impl Thread {
|
|||
|
||||
if let Some(prev_message) =
|
||||
thread.messages.get(ix - 1)
|
||||
{
|
||||
if prev_message.role == Role::Assistant {
|
||||
&& prev_message.role == Role::Assistant {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2476,14 +2474,13 @@ impl Thread {
|
|||
.ok()?;
|
||||
|
||||
// Save thread so its summary can be reused later
|
||||
if let Some(thread) = thread.upgrade() {
|
||||
if let Ok(Ok(save_task)) = cx.update(|cx| {
|
||||
if let Some(thread) = thread.upgrade()
|
||||
&& let Ok(Ok(save_task)) = cx.update(|cx| {
|
||||
thread_store
|
||||
.update(cx, |thread_store, cx| thread_store.save_thread(&thread, cx))
|
||||
}) {
|
||||
save_task.await.log_err();
|
||||
}
|
||||
}
|
||||
|
||||
Some(())
|
||||
});
|
||||
|
@ -2730,13 +2727,11 @@ impl Thread {
|
|||
window: Option<AnyWindowHandle>,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if self.all_tools_finished() {
|
||||
if let Some(ConfiguredModel { model, .. }) = self.configured_model.as_ref() {
|
||||
if !canceled {
|
||||
if self.all_tools_finished()
|
||||
&& let Some(ConfiguredModel { model, .. }) = self.configured_model.as_ref()
|
||||
&& !canceled {
|
||||
self.send_to_model(model.clone(), CompletionIntent::ToolResults, window, cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cx.emit(ThreadEvent::ToolFinished {
|
||||
tool_use_id,
|
||||
|
@ -2922,12 +2917,11 @@ impl Thread {
|
|||
let buffer_store = project.read(app_cx).buffer_store();
|
||||
for buffer_handle in buffer_store.read(app_cx).buffers() {
|
||||
let buffer = buffer_handle.read(app_cx);
|
||||
if buffer.is_dirty() {
|
||||
if let Some(file) = buffer.file() {
|
||||
if buffer.is_dirty()
|
||||
&& let Some(file) = buffer.file() {
|
||||
let path = file.path().to_string_lossy().to_string();
|
||||
unsaved_buffers.push(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.ok();
|
||||
|
@ -3178,14 +3172,13 @@ impl Thread {
|
|||
.model
|
||||
.max_token_count_for_mode(self.completion_mode().into());
|
||||
|
||||
if let Some(exceeded_error) = &self.exceeded_window_error {
|
||||
if model.model.id() == exceeded_error.model_id {
|
||||
if let Some(exceeded_error) = &self.exceeded_window_error
|
||||
&& model.model.id() == exceeded_error.model_id {
|
||||
return Some(TotalTokenUsage {
|
||||
total: exceeded_error.token_count,
|
||||
max,
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
let total = self
|
||||
.token_usage_at_last_message()
|
||||
|
|
|
@ -581,8 +581,8 @@ impl ThreadStore {
|
|||
return;
|
||||
};
|
||||
|
||||
if protocol.capable(context_server::protocol::ServerCapability::Tools) {
|
||||
if let Some(response) = protocol
|
||||
if protocol.capable(context_server::protocol::ServerCapability::Tools)
|
||||
&& let Some(response) = protocol
|
||||
.request::<context_server::types::requests::ListTools>(())
|
||||
.await
|
||||
.log_err()
|
||||
|
@ -609,7 +609,6 @@ impl ThreadStore {
|
|||
.log_err();
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
|
@ -697,14 +696,13 @@ impl SerializedThreadV0_1_0 {
|
|||
let mut messages: Vec<SerializedMessage> = Vec::with_capacity(self.0.messages.len());
|
||||
|
||||
for message in self.0.messages {
|
||||
if message.role == Role::User && !message.tool_results.is_empty() {
|
||||
if let Some(last_message) = messages.last_mut() {
|
||||
if message.role == Role::User && !message.tool_results.is_empty()
|
||||
&& let Some(last_message) = messages.last_mut() {
|
||||
debug_assert!(last_message.role == Role::Assistant);
|
||||
|
||||
last_message.tool_results = message.tool_results;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
messages.push(message);
|
||||
}
|
||||
|
|
|
@ -112,10 +112,10 @@ impl ToolUseState {
|
|||
},
|
||||
);
|
||||
|
||||
if let Some(window) = &mut window {
|
||||
if let Some(tool) = this.tools.read(cx).tool(tool_use, cx) {
|
||||
if let Some(output) = tool_result.output.clone() {
|
||||
if let Some(card) = tool.deserialize_card(
|
||||
if let Some(window) = &mut window
|
||||
&& let Some(tool) = this.tools.read(cx).tool(tool_use, cx)
|
||||
&& let Some(output) = tool_result.output.clone()
|
||||
&& let Some(card) = tool.deserialize_card(
|
||||
output,
|
||||
project.clone(),
|
||||
window,
|
||||
|
@ -123,9 +123,6 @@ impl ToolUseState {
|
|||
) {
|
||||
this.tool_result_cards.insert(tool_use_id, card);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
|
@ -1037,13 +1037,12 @@ impl Thread {
|
|||
log::info!("Running tool {}", tool_use.name);
|
||||
Some(cx.foreground_executor().spawn(async move {
|
||||
let tool_result = tool_result.await.and_then(|output| {
|
||||
if let LanguageModelToolResultContent::Image(_) = &output.llm_output {
|
||||
if !supports_images {
|
||||
if let LanguageModelToolResultContent::Image(_) = &output.llm_output
|
||||
&& !supports_images {
|
||||
return Err(anyhow!(
|
||||
"Attempted to read an image, but this model doesn't support it.",
|
||||
));
|
||||
}
|
||||
}
|
||||
Ok(output)
|
||||
});
|
||||
|
||||
|
|
|
@ -156,14 +156,13 @@ impl EditFileTool {
|
|||
|
||||
// It's also possible that the global config dir is configured to be inside the project,
|
||||
// so check for that edge case too.
|
||||
if let Ok(canonical_path) = std::fs::canonicalize(&input.path) {
|
||||
if canonical_path.starts_with(paths::config_dir()) {
|
||||
if let Ok(canonical_path) = std::fs::canonicalize(&input.path)
|
||||
&& canonical_path.starts_with(paths::config_dir()) {
|
||||
return event_stream.authorize(
|
||||
format!("{} (global settings)", input.display_description),
|
||||
cx,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// Check if path is inside the global config directory
|
||||
// First check if it's already inside project - if not, try to canonicalize
|
||||
|
|
|
@ -179,15 +179,14 @@ impl AgentTool for GrepTool {
|
|||
// Check if this file should be excluded based on its worktree settings
|
||||
if let Ok(Some(project_path)) = project.read_with(cx, |project, cx| {
|
||||
project.find_project_path(&path, cx)
|
||||
}) {
|
||||
if cx.update(|cx| {
|
||||
})
|
||||
&& cx.update(|cx| {
|
||||
let worktree_settings = WorktreeSettings::get(Some((&project_path).into()), cx);
|
||||
worktree_settings.is_path_excluded(&project_path.path)
|
||||
|| worktree_settings.is_path_private(&project_path.path)
|
||||
}).unwrap_or(false) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
while *parse_status.borrow() != ParseStatus::Idle {
|
||||
parse_status.changed().await?;
|
||||
|
@ -275,12 +274,11 @@ impl AgentTool for GrepTool {
|
|||
output.extend(snapshot.text_for_range(range));
|
||||
output.push_str("\n```\n");
|
||||
|
||||
if let Some(ancestor_range) = ancestor_range {
|
||||
if end_row < ancestor_range.end.row {
|
||||
if let Some(ancestor_range) = ancestor_range
|
||||
&& end_row < ancestor_range.end.row {
|
||||
let remaining_lines = ancestor_range.end.row - end_row;
|
||||
writeln!(output, "\n{} lines remaining in ancestor node. Read the file to see all.", remaining_lines)?;
|
||||
}
|
||||
}
|
||||
|
||||
matches_found += 1;
|
||||
}
|
||||
|
|
|
@ -203,15 +203,14 @@ impl AgentConnection for ClaudeAgentConnection {
|
|||
.await
|
||||
}
|
||||
|
||||
if let Some(status) = child.status().await.log_err() {
|
||||
if let Some(thread) = thread_rx.recv().await.ok() {
|
||||
if let Some(status) = child.status().await.log_err()
|
||||
&& let Some(thread) = thread_rx.recv().await.ok() {
|
||||
thread
|
||||
.update(cx, |thread, cx| {
|
||||
thread.emit_server_exited(status, cx);
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
|
|
@ -116,16 +116,14 @@ pub struct LanguageModelParameters {
|
|||
|
||||
impl LanguageModelParameters {
|
||||
pub fn matches(&self, model: &Arc<dyn LanguageModel>) -> bool {
|
||||
if let Some(provider) = &self.provider {
|
||||
if provider.0 != model.provider_id().0 {
|
||||
if let Some(provider) = &self.provider
|
||||
&& provider.0 != model.provider_id().0 {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
if let Some(setting_model) = &self.model {
|
||||
if *setting_model != model.id().0 {
|
||||
if let Some(setting_model) = &self.model
|
||||
&& *setting_model != model.id().0 {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
true
|
||||
}
|
||||
}
|
||||
|
|
|
@ -371,8 +371,8 @@ impl AcpThreadView {
|
|||
let provider_id = provider_id.clone();
|
||||
let this = this.clone();
|
||||
move |_, ev, window, cx| {
|
||||
if let language_model::Event::ProviderStateChanged(updated_provider_id) = &ev {
|
||||
if &provider_id == updated_provider_id {
|
||||
if let language_model::Event::ProviderStateChanged(updated_provider_id) = &ev
|
||||
&& &provider_id == updated_provider_id {
|
||||
this.update(cx, |this, cx| {
|
||||
this.thread_state = Self::initial_state(
|
||||
agent.clone(),
|
||||
|
@ -385,7 +385,6 @@ impl AcpThreadView {
|
|||
})
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
|
@ -547,12 +546,11 @@ impl AcpThreadView {
|
|||
}
|
||||
|
||||
fn send(&mut self, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if let Some(thread) = self.thread() {
|
||||
if thread.read(cx).status() != ThreadStatus::Idle {
|
||||
if let Some(thread) = self.thread()
|
||||
&& thread.read(cx).status() != ThreadStatus::Idle {
|
||||
self.stop_current_and_send_new_message(window, cx);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let contents = self
|
||||
.message_editor
|
||||
|
@ -628,8 +626,8 @@ impl AcpThreadView {
|
|||
return;
|
||||
};
|
||||
|
||||
if let Some(index) = self.editing_message.take() {
|
||||
if let Some(editor) = self
|
||||
if let Some(index) = self.editing_message.take()
|
||||
&& let Some(editor) = self
|
||||
.entry_view_state
|
||||
.read(cx)
|
||||
.entry(index)
|
||||
|
@ -646,8 +644,7 @@ impl AcpThreadView {
|
|||
editor.set_message(user_message.chunks.clone(), window, cx);
|
||||
}
|
||||
})
|
||||
}
|
||||
};
|
||||
};
|
||||
self.focus_handle(cx).focus(window);
|
||||
cx.notify();
|
||||
}
|
||||
|
@ -3265,8 +3262,7 @@ impl AcpThreadView {
|
|||
})
|
||||
})
|
||||
.log_err()
|
||||
{
|
||||
if let Some(pop_up) = screen_window.entity(cx).log_err() {
|
||||
&& let Some(pop_up) = screen_window.entity(cx).log_err() {
|
||||
self.notification_subscriptions
|
||||
.entry(screen_window)
|
||||
.or_insert_with(Vec::new)
|
||||
|
@ -3311,17 +3307,15 @@ impl AcpThreadView {
|
|||
let pop_up_weak = pop_up.downgrade();
|
||||
|
||||
cx.observe_window_activation(window, move |_, window, cx| {
|
||||
if window.is_window_active() {
|
||||
if let Some(pop_up) = pop_up_weak.upgrade() {
|
||||
if window.is_window_active()
|
||||
&& let Some(pop_up) = pop_up_weak.upgrade() {
|
||||
pop_up.update(cx, |_, cx| {
|
||||
cx.emit(AgentNotificationEvent::Dismissed);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn dismiss_notifications(&mut self, cx: &mut Context<Self>) {
|
||||
|
|
|
@ -1072,8 +1072,8 @@ impl ActiveThread {
|
|||
}
|
||||
ThreadEvent::MessageEdited(message_id) => {
|
||||
self.clear_last_error();
|
||||
if let Some(index) = self.messages.iter().position(|id| id == message_id) {
|
||||
if let Some(rendered_message) = self.thread.update(cx, |thread, cx| {
|
||||
if let Some(index) = self.messages.iter().position(|id| id == message_id)
|
||||
&& let Some(rendered_message) = self.thread.update(cx, |thread, cx| {
|
||||
thread.message(*message_id).map(|message| {
|
||||
let mut rendered_message = RenderedMessage {
|
||||
language_registry: self.language_registry.clone(),
|
||||
|
@ -1092,7 +1092,6 @@ impl ActiveThread {
|
|||
self.save_thread(cx);
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
}
|
||||
ThreadEvent::MessageDeleted(message_id) => {
|
||||
self.deleted_message(message_id);
|
||||
|
@ -1272,8 +1271,7 @@ impl ActiveThread {
|
|||
})
|
||||
})
|
||||
.log_err()
|
||||
{
|
||||
if let Some(pop_up) = screen_window.entity(cx).log_err() {
|
||||
&& let Some(pop_up) = screen_window.entity(cx).log_err() {
|
||||
self.notification_subscriptions
|
||||
.entry(screen_window)
|
||||
.or_insert_with(Vec::new)
|
||||
|
@ -1318,17 +1316,15 @@ impl ActiveThread {
|
|||
let pop_up_weak = pop_up.downgrade();
|
||||
|
||||
cx.observe_window_activation(window, move |_, window, cx| {
|
||||
if window.is_window_active() {
|
||||
if let Some(pop_up) = pop_up_weak.upgrade() {
|
||||
if window.is_window_active()
|
||||
&& let Some(pop_up) = pop_up_weak.upgrade() {
|
||||
pop_up.update(cx, |_, cx| {
|
||||
cx.emit(AgentNotificationEvent::Dismissed);
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
/// Spawns a task to save the active thread.
|
||||
|
@ -2269,8 +2265,7 @@ impl ActiveThread {
|
|||
let mut error = None;
|
||||
if let Some(last_restore_checkpoint) =
|
||||
self.thread.read(cx).last_restore_checkpoint()
|
||||
{
|
||||
if last_restore_checkpoint.message_id() == message_id {
|
||||
&& last_restore_checkpoint.message_id() == message_id {
|
||||
match last_restore_checkpoint {
|
||||
LastRestoreCheckpoint::Pending { .. } => is_pending = true,
|
||||
LastRestoreCheckpoint::Error { error: err, .. } => {
|
||||
|
@ -2278,7 +2273,6 @@ impl ActiveThread {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let restore_checkpoint_button =
|
||||
Button::new(("restore-checkpoint", ix), "Restore Checkpoint")
|
||||
|
|
|
@ -163,11 +163,10 @@ impl ConfigurationSource {
|
|||
.read(cx)
|
||||
.text(cx);
|
||||
let settings = serde_json_lenient::from_str::<serde_json::Value>(&text)?;
|
||||
if let Some(settings_validator) = settings_validator {
|
||||
if let Err(error) = settings_validator.validate(&settings) {
|
||||
if let Some(settings_validator) = settings_validator
|
||||
&& let Err(error) = settings_validator.validate(&settings) {
|
||||
return Err(anyhow::anyhow!(error.to_string()));
|
||||
}
|
||||
}
|
||||
Ok((
|
||||
id.clone(),
|
||||
ContextServerSettings::Extension {
|
||||
|
@ -716,25 +715,22 @@ fn wait_for_context_server(
|
|||
project::context_server_store::Event::ServerStatusChanged { server_id, status } => {
|
||||
match status {
|
||||
ContextServerStatus::Running => {
|
||||
if server_id == &context_server_id {
|
||||
if let Some(tx) = tx.lock().unwrap().take() {
|
||||
if server_id == &context_server_id
|
||||
&& let Some(tx) = tx.lock().unwrap().take() {
|
||||
let _ = tx.send(Ok(()));
|
||||
}
|
||||
}
|
||||
}
|
||||
ContextServerStatus::Stopped => {
|
||||
if server_id == &context_server_id {
|
||||
if let Some(tx) = tx.lock().unwrap().take() {
|
||||
if server_id == &context_server_id
|
||||
&& let Some(tx) = tx.lock().unwrap().take() {
|
||||
let _ = tx.send(Err("Context server stopped running".into()));
|
||||
}
|
||||
}
|
||||
}
|
||||
ContextServerStatus::Error(error) => {
|
||||
if server_id == &context_server_id {
|
||||
if let Some(tx) = tx.lock().unwrap().take() {
|
||||
if server_id == &context_server_id
|
||||
&& let Some(tx) = tx.lock().unwrap().take() {
|
||||
let _ = tx.send(Err(error.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
|
|
@ -191,11 +191,10 @@ impl PickerDelegate for ToolPickerDelegate {
|
|||
BTreeMap::default();
|
||||
|
||||
for item in all_items.iter() {
|
||||
if let PickerItem::Tool { server_id, name } = item.clone() {
|
||||
if name.contains(&query) {
|
||||
if let PickerItem::Tool { server_id, name } = item.clone()
|
||||
&& name.contains(&query) {
|
||||
tools_by_provider.entry(server_id).or_default().push(name);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut items = Vec::new();
|
||||
|
|
|
@ -1043,8 +1043,8 @@ impl ToolbarItemView for AgentDiffToolbar {
|
|||
return self.location(cx);
|
||||
}
|
||||
|
||||
if let Some(editor) = item.act_as::<Editor>(cx) {
|
||||
if editor.read(cx).mode().is_full() {
|
||||
if let Some(editor) = item.act_as::<Editor>(cx)
|
||||
&& editor.read(cx).mode().is_full() {
|
||||
let agent_diff = AgentDiff::global(cx);
|
||||
|
||||
self.active_item = Some(AgentDiffToolbarItem::Editor {
|
||||
|
@ -1055,7 +1055,6 @@ impl ToolbarItemView for AgentDiffToolbar {
|
|||
|
||||
return self.location(cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.active_item = None;
|
||||
|
@ -1538,8 +1537,8 @@ impl AgentDiff {
|
|||
) {
|
||||
match event {
|
||||
workspace::Event::ItemAdded { item } => {
|
||||
if let Some(editor) = item.downcast::<Editor>() {
|
||||
if let Some(buffer) = Self::full_editor_buffer(editor.read(cx), cx) {
|
||||
if let Some(editor) = item.downcast::<Editor>()
|
||||
&& let Some(buffer) = Self::full_editor_buffer(editor.read(cx), cx) {
|
||||
self.register_editor(
|
||||
workspace.downgrade(),
|
||||
buffer.clone(),
|
||||
|
@ -1548,7 +1547,6 @@ impl AgentDiff {
|
|||
cx,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
_ => {}
|
||||
}
|
||||
|
@ -1850,8 +1848,8 @@ impl AgentDiff {
|
|||
|
||||
let thread = thread.upgrade()?;
|
||||
|
||||
if let PostReviewState::AllReviewed = review(&editor, &thread, window, cx) {
|
||||
if let Some(curr_buffer) = editor.read(cx).buffer().read(cx).as_singleton() {
|
||||
if let PostReviewState::AllReviewed = review(&editor, &thread, window, cx)
|
||||
&& let Some(curr_buffer) = editor.read(cx).buffer().read(cx).as_singleton() {
|
||||
let changed_buffers = thread.action_log(cx).read(cx).changed_buffers(cx);
|
||||
|
||||
let mut keys = changed_buffers.keys().cycle();
|
||||
|
@ -1867,7 +1865,6 @@ impl AgentDiff {
|
|||
return Some(task);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
return Some(Task::ready(Ok(())));
|
||||
}
|
||||
|
|
|
@ -1398,15 +1398,13 @@ impl AgentPanel {
|
|||
if LanguageModelRegistry::read_global(cx)
|
||||
.default_model()
|
||||
.map_or(true, |model| model.provider.id() != provider.id())
|
||||
{
|
||||
if let Some(model) = provider.default_model(cx) {
|
||||
&& let Some(model) = provider.default_model(cx) {
|
||||
update_settings_file::<AgentSettings>(
|
||||
self.fs.clone(),
|
||||
cx,
|
||||
move |settings, _| settings.set_model(model),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
self.new_thread(&NewThread::default(), window, cx);
|
||||
if let Some((thread, model)) =
|
||||
|
|
|
@ -352,13 +352,12 @@ impl CodegenAlternative {
|
|||
event: &multi_buffer::Event,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if let multi_buffer::Event::TransactionUndone { transaction_id } = event {
|
||||
if self.transformation_transaction_id == Some(*transaction_id) {
|
||||
if let multi_buffer::Event::TransactionUndone { transaction_id } = event
|
||||
&& self.transformation_transaction_id == Some(*transaction_id) {
|
||||
self.transformation_transaction_id = None;
|
||||
self.generation = Task::ready(());
|
||||
cx.emit(CodegenEvent::Undone);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn last_equal_ranges(&self) -> &[Range<Anchor>] {
|
||||
|
@ -576,8 +575,8 @@ impl CodegenAlternative {
|
|||
let mut lines = chunk.split('\n').peekable();
|
||||
while let Some(line) = lines.next() {
|
||||
new_text.push_str(line);
|
||||
if line_indent.is_none() {
|
||||
if let Some(non_whitespace_ch_ix) =
|
||||
if line_indent.is_none()
|
||||
&& let Some(non_whitespace_ch_ix) =
|
||||
new_text.find(|ch: char| !ch.is_whitespace())
|
||||
{
|
||||
line_indent = Some(non_whitespace_ch_ix);
|
||||
|
@ -608,7 +607,6 @@ impl CodegenAlternative {
|
|||
&indent_str.repeat(corrected_indent_len),
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if line_indent.is_some() {
|
||||
let char_ops = diff.push_new(&new_text);
|
||||
|
|
|
@ -368,11 +368,10 @@ impl ContextStrip {
|
|||
_window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if let Some(suggested) = self.suggested_context(cx) {
|
||||
if self.is_suggested_focused(&self.added_contexts(cx)) {
|
||||
if let Some(suggested) = self.suggested_context(cx)
|
||||
&& self.is_suggested_focused(&self.added_contexts(cx)) {
|
||||
self.add_suggested_context(&suggested, cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn add_suggested_context(&mut self, suggested: &SuggestedContext, cx: &mut Context<Self>) {
|
||||
|
|
|
@ -182,8 +182,8 @@ impl InlineAssistant {
|
|||
match event {
|
||||
workspace::Event::UserSavedItem { item, .. } => {
|
||||
// When the user manually saves an editor, automatically accepts all finished transformations.
|
||||
if let Some(editor) = item.upgrade().and_then(|item| item.act_as::<Editor>(cx)) {
|
||||
if let Some(editor_assists) = self.assists_by_editor.get(&editor.downgrade()) {
|
||||
if let Some(editor) = item.upgrade().and_then(|item| item.act_as::<Editor>(cx))
|
||||
&& let Some(editor_assists) = self.assists_by_editor.get(&editor.downgrade()) {
|
||||
for assist_id in editor_assists.assist_ids.clone() {
|
||||
let assist = &self.assists[&assist_id];
|
||||
if let CodegenStatus::Done = assist.codegen.read(cx).status(cx) {
|
||||
|
@ -191,7 +191,6 @@ impl InlineAssistant {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
workspace::Event::ItemAdded { item } => {
|
||||
self.register_workspace_item(&workspace, item.as_ref(), window, cx);
|
||||
|
@ -342,14 +341,13 @@ impl InlineAssistant {
|
|||
)
|
||||
.await
|
||||
.ok();
|
||||
if let Some(answer) = answer {
|
||||
if answer == 0 {
|
||||
if let Some(answer) = answer
|
||||
&& answer == 0 {
|
||||
cx.update(|window, cx| {
|
||||
window.dispatch_action(Box::new(OpenSettings), cx)
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
anyhow::Ok(())
|
||||
})
|
||||
.detach_and_log_err(cx);
|
||||
|
@ -435,12 +433,11 @@ impl InlineAssistant {
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(prev_selection) = selections.last_mut() {
|
||||
if selection.start <= prev_selection.end {
|
||||
if let Some(prev_selection) = selections.last_mut()
|
||||
&& selection.start <= prev_selection.end {
|
||||
prev_selection.end = selection.end;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
let latest_selection = newest_selection.get_or_insert_with(|| selection.clone());
|
||||
if selection.id > latest_selection.id {
|
||||
|
@ -985,15 +982,14 @@ impl InlineAssistant {
|
|||
EditorEvent::SelectionsChanged { .. } => {
|
||||
for assist_id in editor_assists.assist_ids.clone() {
|
||||
let assist = &self.assists[&assist_id];
|
||||
if let Some(decorations) = assist.decorations.as_ref() {
|
||||
if decorations
|
||||
if let Some(decorations) = assist.decorations.as_ref()
|
||||
&& decorations
|
||||
.prompt_editor
|
||||
.focus_handle(cx)
|
||||
.is_focused(window)
|
||||
{
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
editor_assists.scroll_lock = None;
|
||||
|
@ -1503,21 +1499,18 @@ impl InlineAssistant {
|
|||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) -> Option<InlineAssistTarget> {
|
||||
if let Some(terminal_panel) = workspace.panel::<TerminalPanel>(cx) {
|
||||
if terminal_panel
|
||||
if let Some(terminal_panel) = workspace.panel::<TerminalPanel>(cx)
|
||||
&& terminal_panel
|
||||
.read(cx)
|
||||
.focus_handle(cx)
|
||||
.contains_focused(window, cx)
|
||||
{
|
||||
if let Some(terminal_view) = terminal_panel.read(cx).pane().and_then(|pane| {
|
||||
&& let Some(terminal_view) = terminal_panel.read(cx).pane().and_then(|pane| {
|
||||
pane.read(cx)
|
||||
.active_item()
|
||||
.and_then(|t| t.downcast::<TerminalView>())
|
||||
}) {
|
||||
return Some(InlineAssistTarget::Terminal(terminal_view));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let context_editor = agent_panel
|
||||
.and_then(|panel| panel.read(cx).active_context_editor())
|
||||
|
@ -1741,9 +1734,9 @@ impl InlineAssist {
|
|||
return;
|
||||
};
|
||||
|
||||
if let CodegenStatus::Error(error) = codegen.read(cx).status(cx) {
|
||||
if assist.decorations.is_none() {
|
||||
if let Some(workspace) = assist.workspace.upgrade() {
|
||||
if let CodegenStatus::Error(error) = codegen.read(cx).status(cx)
|
||||
&& assist.decorations.is_none()
|
||||
&& let Some(workspace) = assist.workspace.upgrade() {
|
||||
let error = format!("Inline assistant error: {}", error);
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
struct InlineAssistantError;
|
||||
|
@ -1756,8 +1749,6 @@ impl InlineAssist {
|
|||
workspace.show_toast(Toast::new(id, error), cx);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if assist.decorations.is_none() {
|
||||
this.finish_assist(assist_id, false, window, cx);
|
||||
|
@ -1821,19 +1812,17 @@ impl CodeActionProvider for AssistantCodeActionProvider {
|
|||
has_diagnostics = true;
|
||||
}
|
||||
if has_diagnostics {
|
||||
if let Some(symbols_containing_start) = snapshot.symbols_containing(range.start, None) {
|
||||
if let Some(symbol) = symbols_containing_start.last() {
|
||||
if let Some(symbols_containing_start) = snapshot.symbols_containing(range.start, None)
|
||||
&& let Some(symbol) = symbols_containing_start.last() {
|
||||
range.start = cmp::min(range.start, symbol.range.start.to_point(&snapshot));
|
||||
range.end = cmp::max(range.end, symbol.range.end.to_point(&snapshot));
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(symbols_containing_end) = snapshot.symbols_containing(range.end, None) {
|
||||
if let Some(symbol) = symbols_containing_end.last() {
|
||||
if let Some(symbols_containing_end) = snapshot.symbols_containing(range.end, None)
|
||||
&& let Some(symbol) = symbols_containing_end.last() {
|
||||
range.start = cmp::min(range.start, symbol.range.start.to_point(&snapshot));
|
||||
range.end = cmp::max(range.end, symbol.range.end.to_point(&snapshot));
|
||||
}
|
||||
}
|
||||
|
||||
Task::ready(Ok(vec![CodeAction {
|
||||
server_id: language::LanguageServerId(0),
|
||||
|
|
|
@ -388,8 +388,8 @@ impl TerminalInlineAssistant {
|
|||
window: &mut Window,
|
||||
cx: &mut App,
|
||||
) {
|
||||
if let Some(assist) = self.assists.get_mut(&assist_id) {
|
||||
if let Some(prompt_editor) = assist.prompt_editor.as_ref().cloned() {
|
||||
if let Some(assist) = self.assists.get_mut(&assist_id)
|
||||
&& let Some(prompt_editor) = assist.prompt_editor.as_ref().cloned() {
|
||||
assist
|
||||
.terminal
|
||||
.update(cx, |terminal, cx| {
|
||||
|
@ -402,7 +402,6 @@ impl TerminalInlineAssistant {
|
|||
})
|
||||
.log_err();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -450,9 +449,9 @@ impl TerminalInlineAssist {
|
|||
return;
|
||||
};
|
||||
|
||||
if let CodegenStatus::Error(error) = &codegen.read(cx).status {
|
||||
if assist.prompt_editor.is_none() {
|
||||
if let Some(workspace) = assist.workspace.upgrade() {
|
||||
if let CodegenStatus::Error(error) = &codegen.read(cx).status
|
||||
&& assist.prompt_editor.is_none()
|
||||
&& let Some(workspace) = assist.workspace.upgrade() {
|
||||
let error =
|
||||
format!("Terminal inline assistant error: {}", error);
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
|
@ -466,8 +465,6 @@ impl TerminalInlineAssist {
|
|||
workspace.show_toast(Toast::new(id, error), cx);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if assist.prompt_editor.is_none() {
|
||||
this.finish_assist(assist_id, false, false, window, cx);
|
||||
|
|
|
@ -745,8 +745,7 @@ impl TextThreadEditor {
|
|||
) {
|
||||
if let Some(invoked_slash_command) =
|
||||
self.context.read(cx).invoked_slash_command(&command_id)
|
||||
{
|
||||
if let InvokedSlashCommandStatus::Finished = invoked_slash_command.status {
|
||||
&& let InvokedSlashCommandStatus::Finished = invoked_slash_command.status {
|
||||
let run_commands_in_ranges = invoked_slash_command.run_commands_in_ranges.clone();
|
||||
for range in run_commands_in_ranges {
|
||||
let commands = self.context.update(cx, |context, cx| {
|
||||
|
@ -769,7 +768,6 @@ impl TextThreadEditor {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.editor.update(cx, |editor, cx| {
|
||||
if let Some(invoked_slash_command) =
|
||||
|
|
|
@ -166,15 +166,14 @@ impl ThreadHistory {
|
|||
this.all_entries.len().saturating_sub(1),
|
||||
cx,
|
||||
);
|
||||
} else if let Some(prev_id) = previously_selected_entry {
|
||||
if let Some(new_ix) = this
|
||||
} else if let Some(prev_id) = previously_selected_entry
|
||||
&& let Some(new_ix) = this
|
||||
.all_entries
|
||||
.iter()
|
||||
.position(|probe| probe.id() == prev_id)
|
||||
{
|
||||
this.set_selected_entry_index(new_ix, cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
SearchState::Searching { query, .. } | SearchState::Searched { query, .. } => {
|
||||
this.search(query.clone(), cx);
|
||||
|
|
|
@ -1076,8 +1076,8 @@ impl AssistantContext {
|
|||
timestamp,
|
||||
..
|
||||
} => {
|
||||
if let Some(slash_command) = self.invoked_slash_commands.get_mut(&id) {
|
||||
if timestamp > slash_command.timestamp {
|
||||
if let Some(slash_command) = self.invoked_slash_commands.get_mut(&id)
|
||||
&& timestamp > slash_command.timestamp {
|
||||
slash_command.timestamp = timestamp;
|
||||
match error_message {
|
||||
Some(message) => {
|
||||
|
@ -1090,7 +1090,6 @@ impl AssistantContext {
|
|||
}
|
||||
cx.emit(ContextEvent::InvokedSlashCommandChanged { command_id: id });
|
||||
}
|
||||
}
|
||||
}
|
||||
ContextOperation::BufferOperation(_) => unreachable!(),
|
||||
}
|
||||
|
@ -1368,11 +1367,10 @@ impl AssistantContext {
|
|||
continue;
|
||||
}
|
||||
|
||||
if let Some(last_anchor) = last_anchor {
|
||||
if message.id == last_anchor {
|
||||
if let Some(last_anchor) = last_anchor
|
||||
&& message.id == last_anchor {
|
||||
hit_last_anchor = true;
|
||||
}
|
||||
}
|
||||
|
||||
new_anchor_needs_caching = new_anchor_needs_caching
|
||||
|| (invalidated_caches.contains(&message.id) && anchors.contains(&message.id));
|
||||
|
@ -1406,11 +1404,10 @@ impl AssistantContext {
|
|||
if !self.pending_completions.is_empty() {
|
||||
return;
|
||||
}
|
||||
if let Some(cache_configuration) = cache_configuration {
|
||||
if !cache_configuration.should_speculate {
|
||||
if let Some(cache_configuration) = cache_configuration
|
||||
&& !cache_configuration.should_speculate {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
let request = {
|
||||
let mut req = self.to_completion_request(Some(model), cx);
|
||||
|
@ -1552,8 +1549,8 @@ impl AssistantContext {
|
|||
})
|
||||
.map(ToOwned::to_owned)
|
||||
.collect::<SmallVec<_>>();
|
||||
if let Some(command) = self.slash_commands.command(name, cx) {
|
||||
if !command.requires_argument() || !arguments.is_empty() {
|
||||
if let Some(command) = self.slash_commands.command(name, cx)
|
||||
&& (!command.requires_argument() || !arguments.is_empty()) {
|
||||
let start_ix = offset + command_line.name.start - 1;
|
||||
let end_ix = offset
|
||||
+ command_line
|
||||
|
@ -1571,7 +1568,6 @@ impl AssistantContext {
|
|||
updated.push(pending_command.clone());
|
||||
new_commands.push(pending_command);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
offset = lines.offset();
|
||||
|
@ -1799,15 +1795,14 @@ impl AssistantContext {
|
|||
});
|
||||
|
||||
let end = this.buffer.read(cx).anchor_before(insert_position);
|
||||
if run_commands_in_text {
|
||||
if let Some(invoked_slash_command) =
|
||||
if run_commands_in_text
|
||||
&& let Some(invoked_slash_command) =
|
||||
this.invoked_slash_commands.get_mut(&command_id)
|
||||
{
|
||||
invoked_slash_command
|
||||
.run_commands_in_ranges
|
||||
.push(start..end);
|
||||
}
|
||||
}
|
||||
}
|
||||
SlashCommandEvent::EndSection => {
|
||||
if let Some(pending_section) = pending_section_stack.pop() {
|
||||
|
@ -2741,11 +2736,10 @@ impl AssistantContext {
|
|||
}
|
||||
|
||||
this.read_with(cx, |this, _cx| {
|
||||
if let Some(summary) = this.summary.content() {
|
||||
if summary.text.is_empty() {
|
||||
if let Some(summary) = this.summary.content()
|
||||
&& summary.text.is_empty() {
|
||||
bail!("Model generated an empty summary");
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
})??;
|
||||
|
||||
|
@ -2924,8 +2918,8 @@ impl AssistantContext {
|
|||
fs.create_dir(contexts_dir().as_ref()).await?;
|
||||
|
||||
// rename before write ensures that only one file exists
|
||||
if let Some(old_path) = old_path.as_ref() {
|
||||
if new_path.as_path() != old_path.as_ref() {
|
||||
if let Some(old_path) = old_path.as_ref()
|
||||
&& new_path.as_path() != old_path.as_ref() {
|
||||
fs.rename(
|
||||
old_path,
|
||||
&new_path,
|
||||
|
@ -2936,7 +2930,6 @@ impl AssistantContext {
|
|||
)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
// update path before write in case it fails
|
||||
this.update(cx, {
|
||||
|
|
|
@ -894,8 +894,8 @@ impl ContextStore {
|
|||
return;
|
||||
};
|
||||
|
||||
if protocol.capable(context_server::protocol::ServerCapability::Prompts) {
|
||||
if let Some(response) = protocol
|
||||
if protocol.capable(context_server::protocol::ServerCapability::Prompts)
|
||||
&& let Some(response) = protocol
|
||||
.request::<context_server::types::requests::PromptsList>(())
|
||||
.await
|
||||
.log_err()
|
||||
|
@ -922,7 +922,6 @@ impl ContextStore {
|
|||
})
|
||||
.log_err();
|
||||
}
|
||||
}
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
|
|
|
@ -39,11 +39,10 @@ impl SlashCommand for ContextServerSlashCommand {
|
|||
|
||||
fn label(&self, cx: &App) -> language::CodeLabel {
|
||||
let mut parts = vec![self.prompt.name.as_str()];
|
||||
if let Some(args) = &self.prompt.arguments {
|
||||
if let Some(arg) = args.first() {
|
||||
if let Some(args) = &self.prompt.arguments
|
||||
&& let Some(arg) = args.first() {
|
||||
parts.push(arg.name.as_str());
|
||||
}
|
||||
}
|
||||
create_label_for_command(parts[0], &parts[1..], cx)
|
||||
}
|
||||
|
||||
|
|
|
@ -66,8 +66,7 @@ impl SlashCommand for DeltaSlashCommand {
|
|||
.metadata
|
||||
.as_ref()
|
||||
.and_then(|value| serde_json::from_value::<FileCommandMetadata>(value.clone()).ok())
|
||||
{
|
||||
if paths.insert(metadata.path.clone()) {
|
||||
&& paths.insert(metadata.path.clone()) {
|
||||
file_command_old_outputs.push(
|
||||
context_buffer
|
||||
.as_rope()
|
||||
|
@ -83,7 +82,6 @@ impl SlashCommand for DeltaSlashCommand {
|
|||
cx,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cx.background_spawn(async move {
|
||||
|
@ -95,10 +93,9 @@ impl SlashCommand for DeltaSlashCommand {
|
|||
.into_iter()
|
||||
.zip(file_command_new_outputs)
|
||||
{
|
||||
if let Ok(new_output) = new_output {
|
||||
if let Ok(new_output) = SlashCommandOutput::from_event_stream(new_output).await
|
||||
{
|
||||
if let Some(file_command_range) = new_output.sections.first() {
|
||||
if let Ok(new_output) = new_output
|
||||
&& let Ok(new_output) = SlashCommandOutput::from_event_stream(new_output).await
|
||||
&& let Some(file_command_range) = new_output.sections.first() {
|
||||
let new_text = &new_output.text[file_command_range.range.clone()];
|
||||
if old_text.chars().ne(new_text.chars()) {
|
||||
changes_detected = true;
|
||||
|
@ -114,8 +111,6 @@ impl SlashCommand for DeltaSlashCommand {
|
|||
output.text.push_str(&new_output.text);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
anyhow::ensure!(changes_detected, "no new changes detected");
|
||||
|
|
|
@ -280,11 +280,10 @@ fn collect_diagnostics(
|
|||
|
||||
let mut project_summary = DiagnosticSummary::default();
|
||||
for (project_path, path, summary) in diagnostic_summaries {
|
||||
if let Some(path_matcher) = &options.path_matcher {
|
||||
if !path_matcher.is_match(&path) {
|
||||
if let Some(path_matcher) = &options.path_matcher
|
||||
&& !path_matcher.is_match(&path) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
project_summary.error_count += summary.error_count;
|
||||
if options.include_warnings {
|
||||
|
|
|
@ -195,17 +195,14 @@ fn tab_items_for_queries(
|
|||
}
|
||||
|
||||
for editor in workspace.items_of_type::<Editor>(cx) {
|
||||
if let Some(buffer) = editor.read(cx).buffer().read(cx).as_singleton() {
|
||||
if let Some(timestamp) =
|
||||
if let Some(buffer) = editor.read(cx).buffer().read(cx).as_singleton()
|
||||
&& let Some(timestamp) =
|
||||
timestamps_by_entity_id.get(&editor.entity_id())
|
||||
{
|
||||
if visited_buffers.insert(buffer.read(cx).remote_id()) {
|
||||
&& visited_buffers.insert(buffer.read(cx).remote_id()) {
|
||||
let snapshot = buffer.read(cx).snapshot();
|
||||
let full_path = snapshot.resolve_file_path(cx, true);
|
||||
open_buffers.push((full_path, snapshot, *timestamp));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(open_buffers)
|
||||
|
|
|
@ -24,8 +24,8 @@ pub fn adapt_schema_to_format(
|
|||
fn preprocess_json_schema(json: &mut Value) -> Result<()> {
|
||||
// `additionalProperties` defaults to `false` unless explicitly specified.
|
||||
// This prevents models from hallucinating tool parameters.
|
||||
if let Value::Object(obj) = json {
|
||||
if matches!(obj.get("type"), Some(Value::String(s)) if s == "object") {
|
||||
if let Value::Object(obj) = json
|
||||
&& matches!(obj.get("type"), Some(Value::String(s)) if s == "object") {
|
||||
if !obj.contains_key("additionalProperties") {
|
||||
obj.insert("additionalProperties".to_string(), Value::Bool(false));
|
||||
}
|
||||
|
@ -35,7 +35,6 @@ fn preprocess_json_schema(json: &mut Value) -> Result<()> {
|
|||
obj.insert("properties".to_string(), Value::Object(Default::default()));
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -59,11 +58,10 @@ fn adapt_to_json_schema_subset(json: &mut Value) -> Result<()> {
|
|||
("optional", |value| value.is_boolean()),
|
||||
];
|
||||
for (key, predicate) in KEYS_TO_REMOVE {
|
||||
if let Some(value) = obj.get(key) {
|
||||
if predicate(value) {
|
||||
if let Some(value) = obj.get(key)
|
||||
&& predicate(value) {
|
||||
obj.remove(key);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If a type is not specified for an input parameter, add a default type
|
||||
|
@ -77,13 +75,12 @@ fn adapt_to_json_schema_subset(json: &mut Value) -> Result<()> {
|
|||
}
|
||||
|
||||
// Handle oneOf -> anyOf conversion
|
||||
if let Some(subschemas) = obj.get_mut("oneOf") {
|
||||
if subschemas.is_array() {
|
||||
if let Some(subschemas) = obj.get_mut("oneOf")
|
||||
&& subschemas.is_array() {
|
||||
let subschemas_clone = subschemas.clone();
|
||||
obj.remove("oneOf");
|
||||
obj.insert("anyOf".to_string(), subschemas_clone);
|
||||
}
|
||||
}
|
||||
|
||||
// Recursively process all nested objects and arrays
|
||||
for (_, value) in obj.iter_mut() {
|
||||
|
|
|
@ -672,8 +672,8 @@ impl EditAgent {
|
|||
cx: &mut AsyncApp,
|
||||
) -> Result<BoxStream<'static, Result<String, LanguageModelCompletionError>>> {
|
||||
let mut messages_iter = conversation.messages.iter_mut();
|
||||
if let Some(last_message) = messages_iter.next_back() {
|
||||
if last_message.role == Role::Assistant {
|
||||
if let Some(last_message) = messages_iter.next_back()
|
||||
&& last_message.role == Role::Assistant {
|
||||
let old_content_len = last_message.content.len();
|
||||
last_message
|
||||
.content
|
||||
|
@ -685,18 +685,16 @@ impl EditAgent {
|
|||
// (e.g., the message will look very different on the next
|
||||
// request). Thus, we move the flag to the message prior to it,
|
||||
// as it will still be a valid prefix of the conversation.
|
||||
if old_content_len != new_content_len && last_message.cache {
|
||||
if let Some(prev_message) = messages_iter.next_back() {
|
||||
if old_content_len != new_content_len && last_message.cache
|
||||
&& let Some(prev_message) = messages_iter.next_back() {
|
||||
last_message.cache = false;
|
||||
prev_message.cache = true;
|
||||
}
|
||||
}
|
||||
|
||||
if last_message.content.is_empty() {
|
||||
conversation.messages.pop();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
conversation.messages.push(LanguageModelRequestMessage {
|
||||
role: Role::User,
|
||||
|
|
|
@ -1283,15 +1283,14 @@ impl EvalAssertion {
|
|||
|
||||
// Parse the score from the response
|
||||
let re = regex::Regex::new(r"<score>(\d+)</score>").unwrap();
|
||||
if let Some(captures) = re.captures(&output) {
|
||||
if let Some(score_match) = captures.get(1) {
|
||||
if let Some(captures) = re.captures(&output)
|
||||
&& let Some(score_match) = captures.get(1) {
|
||||
let score = score_match.as_str().parse().unwrap_or(0);
|
||||
return Ok(EvalAssertionOutcome {
|
||||
score,
|
||||
message: Some(output),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
anyhow::bail!("No score found in response. Raw output: {output}");
|
||||
})
|
||||
|
|
|
@ -155,11 +155,10 @@ impl Tool for EditFileTool {
|
|||
|
||||
// It's also possible that the global config dir is configured to be inside the project,
|
||||
// so check for that edge case too.
|
||||
if let Ok(canonical_path) = std::fs::canonicalize(&input.path) {
|
||||
if canonical_path.starts_with(paths::config_dir()) {
|
||||
if let Ok(canonical_path) = std::fs::canonicalize(&input.path)
|
||||
&& canonical_path.starts_with(paths::config_dir()) {
|
||||
return true;
|
||||
}
|
||||
}
|
||||
|
||||
// Check if path is inside the global config directory
|
||||
// First check if it's already inside project - if not, try to canonicalize
|
||||
|
@ -199,11 +198,10 @@ impl Tool for EditFileTool {
|
|||
.any(|c| c.as_os_str() == local_settings_folder.as_os_str())
|
||||
{
|
||||
description.push_str(" (local settings)");
|
||||
} else if let Ok(canonical_path) = std::fs::canonicalize(&input.path) {
|
||||
if canonical_path.starts_with(paths::config_dir()) {
|
||||
} else if let Ok(canonical_path) = std::fs::canonicalize(&input.path)
|
||||
&& canonical_path.starts_with(paths::config_dir()) {
|
||||
description.push_str(" (global settings)");
|
||||
}
|
||||
}
|
||||
|
||||
description
|
||||
}
|
||||
|
|
|
@ -188,15 +188,14 @@ impl Tool for GrepTool {
|
|||
// Check if this file should be excluded based on its worktree settings
|
||||
if let Ok(Some(project_path)) = project.read_with(cx, |project, cx| {
|
||||
project.find_project_path(&path, cx)
|
||||
}) {
|
||||
if cx.update(|cx| {
|
||||
})
|
||||
&& cx.update(|cx| {
|
||||
let worktree_settings = WorktreeSettings::get(Some((&project_path).into()), cx);
|
||||
worktree_settings.is_path_excluded(&project_path.path)
|
||||
|| worktree_settings.is_path_private(&project_path.path)
|
||||
}).unwrap_or(false) {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
while *parse_status.borrow() != ParseStatus::Idle {
|
||||
parse_status.changed().await?;
|
||||
|
@ -284,12 +283,11 @@ impl Tool for GrepTool {
|
|||
output.extend(snapshot.text_for_range(range));
|
||||
output.push_str("\n```\n");
|
||||
|
||||
if let Some(ancestor_range) = ancestor_range {
|
||||
if end_row < ancestor_range.end.row {
|
||||
if let Some(ancestor_range) = ancestor_range
|
||||
&& end_row < ancestor_range.end.row {
|
||||
let remaining_lines = ancestor_range.end.row - end_row;
|
||||
writeln!(output, "\n{} lines remaining in ancestor node. Read the file to see all.", remaining_lines)?;
|
||||
}
|
||||
}
|
||||
|
||||
matches_found += 1;
|
||||
}
|
||||
|
|
|
@ -43,13 +43,11 @@ impl Transform for ToJsonSchemaSubsetTransform {
|
|||
fn transform(&mut self, schema: &mut Schema) {
|
||||
// Ensure that the type field is not an array, this happens when we use
|
||||
// Option<T>, the type will be [T, "null"].
|
||||
if let Some(type_field) = schema.get_mut("type") {
|
||||
if let Some(types) = type_field.as_array() {
|
||||
if let Some(first_type) = types.first() {
|
||||
if let Some(type_field) = schema.get_mut("type")
|
||||
&& let Some(types) = type_field.as_array()
|
||||
&& let Some(first_type) = types.first() {
|
||||
*type_field = first_type.clone();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// oneOf is not supported, use anyOf instead
|
||||
if let Some(one_of) = schema.remove("oneOf") {
|
||||
|
|
|
@ -186,11 +186,11 @@ unsafe extern "system" fn wnd_proc(
|
|||
}),
|
||||
WM_TERMINATE => {
|
||||
with_dialog_data(hwnd, |data| {
|
||||
if let Ok(result) = data.borrow_mut().rx.recv() {
|
||||
if let Err(e) = result {
|
||||
log::error!("Failed to update Zed: {:?}", e);
|
||||
show_error(format!("Error: {:?}", e));
|
||||
}
|
||||
if let Ok(result) = data.borrow_mut().rx.recv()
|
||||
&& let Err(e) = result
|
||||
{
|
||||
log::error!("Failed to update Zed: {:?}", e);
|
||||
show_error(format!("Error: {:?}", e));
|
||||
}
|
||||
});
|
||||
unsafe { PostQuitMessage(0) };
|
||||
|
|
|
@ -82,12 +82,11 @@ impl Render for Breadcrumbs {
|
|||
}
|
||||
text_style.color = Color::Muted.color(cx);
|
||||
|
||||
if index == 0 && !TabBarSettings::get_global(cx).show && active_item.is_dirty(cx) {
|
||||
if let Some(styled_element) = apply_dirty_filename_style(&segment, &text_style, cx)
|
||||
if index == 0 && !TabBarSettings::get_global(cx).show && active_item.is_dirty(cx)
|
||||
&& let Some(styled_element) = apply_dirty_filename_style(&segment, &text_style, cx)
|
||||
{
|
||||
return styled_element;
|
||||
}
|
||||
}
|
||||
|
||||
StyledText::new(segment.text.replace('\n', "⏎"))
|
||||
.with_default_highlights(&text_style, segment.highlights.unwrap_or_default())
|
||||
|
|
|
@ -572,15 +572,14 @@ impl BufferDiffInner {
|
|||
pending_range.end.column = 0;
|
||||
}
|
||||
|
||||
if pending_range == (start_point..end_point) {
|
||||
if !buffer.has_edits_since_in_range(
|
||||
if pending_range == (start_point..end_point)
|
||||
&& !buffer.has_edits_since_in_range(
|
||||
&pending_hunk.buffer_version,
|
||||
start_anchor..end_anchor,
|
||||
) {
|
||||
has_pending = true;
|
||||
secondary_status = pending_hunk.new_status;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let (Some(secondary_cursor), false) = (secondary_cursor.as_mut(), has_pending) {
|
||||
|
@ -1036,8 +1035,8 @@ impl BufferDiff {
|
|||
_ => (true, Some(text::Anchor::MIN..text::Anchor::MAX)),
|
||||
};
|
||||
|
||||
if let Some(secondary_changed_range) = secondary_diff_change {
|
||||
if let Some(secondary_hunk_range) =
|
||||
if let Some(secondary_changed_range) = secondary_diff_change
|
||||
&& let Some(secondary_hunk_range) =
|
||||
self.range_to_hunk_range(secondary_changed_range, buffer, cx)
|
||||
{
|
||||
if let Some(range) = &mut changed_range {
|
||||
|
@ -1047,7 +1046,6 @@ impl BufferDiff {
|
|||
changed_range = Some(secondary_hunk_range);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let state = &mut self.inner;
|
||||
state.base_text_exists = new_state.base_text_exists;
|
||||
|
|
|
@ -827,8 +827,8 @@ impl Room {
|
|||
);
|
||||
|
||||
Audio::play_sound(Sound::Joined, cx);
|
||||
if let Some(livekit_participants) = &livekit_participants {
|
||||
if let Some(livekit_participant) = livekit_participants
|
||||
if let Some(livekit_participants) = &livekit_participants
|
||||
&& let Some(livekit_participant) = livekit_participants
|
||||
.get(&ParticipantIdentity(user.id.to_string()))
|
||||
{
|
||||
for publication in
|
||||
|
@ -847,7 +847,6 @@ impl Room {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -940,11 +939,10 @@ impl Room {
|
|||
self.client.user_id()
|
||||
)
|
||||
})?;
|
||||
if self.live_kit.as_ref().map_or(true, |kit| kit.deafened) {
|
||||
if publication.is_audio() {
|
||||
if self.live_kit.as_ref().map_or(true, |kit| kit.deafened)
|
||||
&& publication.is_audio() {
|
||||
publication.set_enabled(false, cx);
|
||||
}
|
||||
}
|
||||
match track {
|
||||
livekit_client::RemoteTrack::Audio(track) => {
|
||||
cx.emit(Event::RemoteAudioTracksChanged {
|
||||
|
@ -1005,11 +1003,10 @@ impl Room {
|
|||
for (sid, participant) in &mut self.remote_participants {
|
||||
participant.speaking = speaker_ids.binary_search(sid).is_ok();
|
||||
}
|
||||
if let Some(id) = self.client.user_id() {
|
||||
if let Some(room) = &mut self.live_kit {
|
||||
if let Some(id) = self.client.user_id()
|
||||
&& let Some(room) = &mut self.live_kit {
|
||||
room.speaking = speaker_ids.binary_search(&id).is_ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
RoomEvent::TrackMuted {
|
||||
|
@ -1042,19 +1039,15 @@ impl Room {
|
|||
if let LocalTrack::Published {
|
||||
track_publication, ..
|
||||
} = &room.microphone_track
|
||||
{
|
||||
if track_publication.sid() == publication.sid() {
|
||||
&& track_publication.sid() == publication.sid() {
|
||||
room.microphone_track = LocalTrack::None;
|
||||
}
|
||||
}
|
||||
if let LocalTrack::Published {
|
||||
track_publication, ..
|
||||
} = &room.screen_track
|
||||
{
|
||||
if track_publication.sid() == publication.sid() {
|
||||
&& track_publication.sid() == publication.sid() {
|
||||
room.screen_track = LocalTrack::None;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1484,11 +1477,10 @@ impl Room {
|
|||
|
||||
self.set_deafened(deafened, cx);
|
||||
|
||||
if should_change_mute {
|
||||
if let Some(task) = self.set_mute(deafened, cx) {
|
||||
if should_change_mute
|
||||
&& let Some(task) = self.set_mute(deafened, cx) {
|
||||
task.detach_and_log_err(cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -191,13 +191,11 @@ impl ChannelBuffer {
|
|||
operation,
|
||||
is_local: true,
|
||||
} => {
|
||||
if *ZED_ALWAYS_ACTIVE {
|
||||
if let language::Operation::UpdateSelections { selections, .. } = operation {
|
||||
if selections.is_empty() {
|
||||
if *ZED_ALWAYS_ACTIVE
|
||||
&& let language::Operation::UpdateSelections { selections, .. } = operation
|
||||
&& selections.is_empty() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
let operation = language::proto::serialize_operation(operation);
|
||||
self.client
|
||||
.send(proto::UpdateChannelBuffer {
|
||||
|
|
|
@ -329,8 +329,8 @@ impl ChannelChat {
|
|||
loop {
|
||||
let step = chat
|
||||
.update(&mut cx, |chat, cx| {
|
||||
if let Some(first_id) = chat.first_loaded_message_id() {
|
||||
if first_id <= message_id {
|
||||
if let Some(first_id) = chat.first_loaded_message_id()
|
||||
&& first_id <= message_id {
|
||||
let mut cursor = chat
|
||||
.messages
|
||||
.cursor::<Dimensions<ChannelMessageId, Count>>(&());
|
||||
|
@ -347,7 +347,6 @@ impl ChannelChat {
|
|||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
ControlFlow::Continue(chat.load_more_messages(cx))
|
||||
})
|
||||
.log_err()?;
|
||||
|
@ -359,8 +358,8 @@ impl ChannelChat {
|
|||
}
|
||||
|
||||
pub fn acknowledge_last_message(&mut self, cx: &mut Context<Self>) {
|
||||
if let ChannelMessageId::Saved(latest_message_id) = self.messages.summary().max_id {
|
||||
if self
|
||||
if let ChannelMessageId::Saved(latest_message_id) = self.messages.summary().max_id
|
||||
&& self
|
||||
.last_acknowledged_id
|
||||
.map_or(true, |acknowledged_id| acknowledged_id < latest_message_id)
|
||||
{
|
||||
|
@ -375,7 +374,6 @@ impl ChannelChat {
|
|||
store.acknowledge_message_id(self.channel_id, latest_message_id, cx);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
async fn handle_loaded_messages(
|
||||
|
@ -407,11 +405,10 @@ impl ChannelChat {
|
|||
let missing_ancestors = loaded_messages
|
||||
.iter()
|
||||
.filter_map(|message| {
|
||||
if let Some(ancestor_id) = message.reply_to_message_id {
|
||||
if !loaded_message_ids.contains(&ancestor_id) {
|
||||
if let Some(ancestor_id) = message.reply_to_message_id
|
||||
&& !loaded_message_ids.contains(&ancestor_id) {
|
||||
return Some(ancestor_id);
|
||||
}
|
||||
}
|
||||
None
|
||||
})
|
||||
.collect::<Vec<_>>();
|
||||
|
@ -646,8 +643,8 @@ impl ChannelChat {
|
|||
fn message_removed(&mut self, id: u64, cx: &mut Context<Self>) {
|
||||
let mut cursor = self.messages.cursor::<ChannelMessageId>(&());
|
||||
let mut messages = cursor.slice(&ChannelMessageId::Saved(id), Bias::Left);
|
||||
if let Some(item) = cursor.item() {
|
||||
if item.id == ChannelMessageId::Saved(id) {
|
||||
if let Some(item) = cursor.item()
|
||||
&& item.id == ChannelMessageId::Saved(id) {
|
||||
let deleted_message_ix = messages.summary().count;
|
||||
cursor.next();
|
||||
messages.append(cursor.suffix(), &());
|
||||
|
@ -660,11 +657,10 @@ impl ChannelChat {
|
|||
let summary = self.messages.summary();
|
||||
if summary.count == 0 {
|
||||
store.set_acknowledged_message_id(self.channel_id, None);
|
||||
} else if deleted_message_ix == summary.count {
|
||||
if let ChannelMessageId::Saved(id) = summary.max_id {
|
||||
} else if deleted_message_ix == summary.count
|
||||
&& let ChannelMessageId::Saved(id) = summary.max_id {
|
||||
store.set_acknowledged_message_id(self.channel_id, Some(id));
|
||||
}
|
||||
}
|
||||
});
|
||||
|
||||
cx.emit(ChannelChatEvent::MessagesUpdated {
|
||||
|
@ -672,7 +668,6 @@ impl ChannelChat {
|
|||
new_count: 0,
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn message_update(
|
||||
|
|
|
@ -262,13 +262,12 @@ impl ChannelStore {
|
|||
}
|
||||
}
|
||||
status = status_receiver.next().fuse() => {
|
||||
if let Some(status) = status {
|
||||
if status.is_connected() {
|
||||
if let Some(status) = status
|
||||
&& status.is_connected() {
|
||||
this.update(cx, |this, _cx| {
|
||||
this.initialize();
|
||||
}).ok();
|
||||
}
|
||||
}
|
||||
continue;
|
||||
}
|
||||
_ = timer => {
|
||||
|
@ -336,11 +335,10 @@ impl ChannelStore {
|
|||
}
|
||||
|
||||
pub fn has_open_channel_buffer(&self, channel_id: ChannelId, _cx: &App) -> bool {
|
||||
if let Some(buffer) = self.opened_buffers.get(&channel_id) {
|
||||
if let OpenEntityHandle::Open(buffer) = buffer {
|
||||
if let Some(buffer) = self.opened_buffers.get(&channel_id)
|
||||
&& let OpenEntityHandle::Open(buffer) = buffer {
|
||||
return buffer.upgrade().is_some();
|
||||
}
|
||||
}
|
||||
false
|
||||
}
|
||||
|
||||
|
@ -408,14 +406,13 @@ impl ChannelStore {
|
|||
|
||||
pub fn last_acknowledge_message_id(&self, channel_id: ChannelId) -> Option<u64> {
|
||||
self.channel_states.get(&channel_id).and_then(|state| {
|
||||
if let Some(last_message_id) = state.latest_chat_message {
|
||||
if state
|
||||
if let Some(last_message_id) = state.latest_chat_message
|
||||
&& state
|
||||
.last_acknowledged_message_id()
|
||||
.is_some_and(|id| id < last_message_id)
|
||||
{
|
||||
return state.last_acknowledged_message_id();
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
})
|
||||
|
@ -962,19 +959,18 @@ impl ChannelStore {
|
|||
self.disconnect_channel_buffers_task.take();
|
||||
|
||||
for chat in self.opened_chats.values() {
|
||||
if let OpenEntityHandle::Open(chat) = chat {
|
||||
if let Some(chat) = chat.upgrade() {
|
||||
if let OpenEntityHandle::Open(chat) = chat
|
||||
&& let Some(chat) = chat.upgrade() {
|
||||
chat.update(cx, |chat, cx| {
|
||||
chat.rejoin(cx);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut buffer_versions = Vec::new();
|
||||
for buffer in self.opened_buffers.values() {
|
||||
if let OpenEntityHandle::Open(buffer) = buffer {
|
||||
if let Some(buffer) = buffer.upgrade() {
|
||||
if let OpenEntityHandle::Open(buffer) = buffer
|
||||
&& let Some(buffer) = buffer.upgrade() {
|
||||
let channel_buffer = buffer.read(cx);
|
||||
let buffer = channel_buffer.buffer().read(cx);
|
||||
buffer_versions.push(proto::ChannelBufferVersion {
|
||||
|
@ -983,7 +979,6 @@ impl ChannelStore {
|
|||
version: language::proto::serialize_version(&buffer.version()),
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if buffer_versions.is_empty() {
|
||||
|
@ -1078,11 +1073,10 @@ impl ChannelStore {
|
|||
if let Some(this) = this.upgrade() {
|
||||
this.update(cx, |this, cx| {
|
||||
for (_, buffer) in &this.opened_buffers {
|
||||
if let OpenEntityHandle::Open(buffer) = &buffer {
|
||||
if let Some(buffer) = buffer.upgrade() {
|
||||
if let OpenEntityHandle::Open(buffer) = &buffer
|
||||
&& let Some(buffer) = buffer.upgrade() {
|
||||
buffer.update(cx, |buffer, cx| buffer.disconnect(cx));
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
.ok();
|
||||
|
@ -1157,11 +1151,9 @@ impl ChannelStore {
|
|||
}
|
||||
if let Some(OpenEntityHandle::Open(buffer)) =
|
||||
self.opened_buffers.remove(&channel_id)
|
||||
{
|
||||
if let Some(buffer) = buffer.upgrade() {
|
||||
&& let Some(buffer) = buffer.upgrade() {
|
||||
buffer.update(cx, ChannelBuffer::disconnect);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1170,13 +1162,11 @@ impl ChannelStore {
|
|||
let id = ChannelId(channel.id);
|
||||
let channel_changed = index.insert(channel);
|
||||
|
||||
if channel_changed {
|
||||
if let Some(OpenEntityHandle::Open(buffer)) = self.opened_buffers.get(&id) {
|
||||
if let Some(buffer) = buffer.upgrade() {
|
||||
if channel_changed
|
||||
&& let Some(OpenEntityHandle::Open(buffer)) = self.opened_buffers.get(&id)
|
||||
&& let Some(buffer) = buffer.upgrade() {
|
||||
buffer.update(cx, ChannelBuffer::channel_changed);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for latest_buffer_version in payload.latest_channel_buffer_versions {
|
||||
|
|
|
@ -587,13 +587,10 @@ mod flatpak {
|
|||
pub fn set_bin_if_no_escape(mut args: super::Args) -> super::Args {
|
||||
if env::var(NO_ESCAPE_ENV_NAME).is_ok()
|
||||
&& env::var("FLATPAK_ID").map_or(false, |id| id.starts_with("dev.zed.Zed"))
|
||||
&& args.zed.is_none()
|
||||
{
|
||||
if args.zed.is_none() {
|
||||
args.zed = Some("/app/libexec/zed-editor".into());
|
||||
unsafe {
|
||||
env::set_var("ZED_UPDATE_EXPLANATION", "Please use flatpak to update zed")
|
||||
};
|
||||
}
|
||||
args.zed = Some("/app/libexec/zed-editor".into());
|
||||
unsafe { env::set_var("ZED_UPDATE_EXPLANATION", "Please use flatpak to update zed") };
|
||||
}
|
||||
args
|
||||
}
|
||||
|
|
|
@ -864,14 +864,13 @@ impl Client {
|
|||
let mut credentials = None;
|
||||
|
||||
let old_credentials = self.state.read().credentials.clone();
|
||||
if let Some(old_credentials) = old_credentials {
|
||||
if self.validate_credentials(&old_credentials, cx).await? {
|
||||
if let Some(old_credentials) = old_credentials
|
||||
&& self.validate_credentials(&old_credentials, cx).await? {
|
||||
credentials = Some(old_credentials);
|
||||
}
|
||||
}
|
||||
|
||||
if credentials.is_none() && try_provider {
|
||||
if let Some(stored_credentials) = self.credentials_provider.read_credentials(cx).await {
|
||||
if credentials.is_none() && try_provider
|
||||
&& let Some(stored_credentials) = self.credentials_provider.read_credentials(cx).await {
|
||||
if self.validate_credentials(&stored_credentials, cx).await? {
|
||||
credentials = Some(stored_credentials);
|
||||
} else {
|
||||
|
@ -881,7 +880,6 @@ impl Client {
|
|||
.log_err();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if credentials.is_none() {
|
||||
let mut status_rx = self.status();
|
||||
|
|
|
@ -894,11 +894,10 @@ impl UserStore {
|
|||
let mut ret = Vec::with_capacity(users.len());
|
||||
for user in users {
|
||||
let user = User::new(user);
|
||||
if let Some(old) = self.users.insert(user.id, user.clone()) {
|
||||
if old.github_login != user.github_login {
|
||||
if let Some(old) = self.users.insert(user.id, user.clone())
|
||||
&& old.github_login != user.github_login {
|
||||
self.by_github_login.remove(&old.github_login);
|
||||
}
|
||||
}
|
||||
self.by_github_login
|
||||
.insert(user.github_login.clone(), user.id);
|
||||
ret.push(user)
|
||||
|
|
|
@ -149,8 +149,8 @@ pub async fn post_crash(
|
|||
"crash report"
|
||||
);
|
||||
|
||||
if let Some(kinesis_client) = app.kinesis_client.clone() {
|
||||
if let Some(stream) = app.config.kinesis_stream.clone() {
|
||||
if let Some(kinesis_client) = app.kinesis_client.clone()
|
||||
&& let Some(stream) = app.config.kinesis_stream.clone() {
|
||||
let properties = json!({
|
||||
"app_version": report.header.app_version,
|
||||
"os_version": report.header.os_version,
|
||||
|
@ -178,7 +178,6 @@ pub async fn post_crash(
|
|||
.await
|
||||
.log_err();
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(slack_panics_webhook) = app.config.slack_panics_webhook.clone() {
|
||||
let payload = slack::WebhookBody::new(|w| {
|
||||
|
@ -359,8 +358,8 @@ pub async fn post_panic(
|
|||
"panic report"
|
||||
);
|
||||
|
||||
if let Some(kinesis_client) = app.kinesis_client.clone() {
|
||||
if let Some(stream) = app.config.kinesis_stream.clone() {
|
||||
if let Some(kinesis_client) = app.kinesis_client.clone()
|
||||
&& let Some(stream) = app.config.kinesis_stream.clone() {
|
||||
let properties = json!({
|
||||
"app_version": panic.app_version,
|
||||
"os_name": panic.os_name,
|
||||
|
@ -387,7 +386,6 @@ pub async fn post_panic(
|
|||
.await
|
||||
.log_err();
|
||||
}
|
||||
}
|
||||
|
||||
if !report_to_slack(&panic) {
|
||||
return Ok(());
|
||||
|
@ -518,8 +516,8 @@ pub async fn post_events(
|
|||
let first_event_at = chrono::Utc::now()
|
||||
- chrono::Duration::milliseconds(last_event.milliseconds_since_first_event);
|
||||
|
||||
if let Some(kinesis_client) = app.kinesis_client.clone() {
|
||||
if let Some(stream) = app.config.kinesis_stream.clone() {
|
||||
if let Some(kinesis_client) = app.kinesis_client.clone()
|
||||
&& let Some(stream) = app.config.kinesis_stream.clone() {
|
||||
let mut request = kinesis_client.put_records().stream_name(stream);
|
||||
let mut has_records = false;
|
||||
for row in for_snowflake(
|
||||
|
@ -542,8 +540,7 @@ pub async fn post_events(
|
|||
if has_records {
|
||||
request.send().await.log_err();
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
|
|
@ -337,8 +337,7 @@ async fn fetch_extensions_from_blob_store(
|
|||
if known_versions
|
||||
.binary_search_by_key(&published_version, |known_version| known_version)
|
||||
.is_err()
|
||||
{
|
||||
if let Some(extension) = fetch_extension_manifest(
|
||||
&& let Some(extension) = fetch_extension_manifest(
|
||||
blob_store_client,
|
||||
blob_store_bucket,
|
||||
extension_id,
|
||||
|
@ -352,7 +351,6 @@ async fn fetch_extensions_from_blob_store(
|
|||
.or_default()
|
||||
.push(extension);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -79,8 +79,8 @@ pub async fn validate_header<B>(mut req: Request<B>, next: Next<B>) -> impl Into
|
|||
verify_access_token(access_token, user_id, &state.db).await
|
||||
};
|
||||
|
||||
if let Ok(validate_result) = validate_result {
|
||||
if validate_result.is_valid {
|
||||
if let Ok(validate_result) = validate_result
|
||||
&& validate_result.is_valid {
|
||||
let user = state
|
||||
.db
|
||||
.get_user_by_id(user_id)
|
||||
|
@ -100,7 +100,6 @@ pub async fn validate_header<B>(mut req: Request<B>, next: Next<B>) -> impl Into
|
|||
};
|
||||
return Ok::<_, Error>(next.run(req).await);
|
||||
}
|
||||
}
|
||||
|
||||
Err(Error::http(
|
||||
StatusCode::UNAUTHORIZED,
|
||||
|
|
|
@ -87,11 +87,10 @@ impl Database {
|
|||
continue;
|
||||
};
|
||||
|
||||
if let Some((_, max_extension_version)) = &max_versions.get(&version.extension_id) {
|
||||
if max_extension_version > &extension_version {
|
||||
if let Some((_, max_extension_version)) = &max_versions.get(&version.extension_id)
|
||||
&& max_extension_version > &extension_version {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(constraints) = constraints {
|
||||
if !constraints
|
||||
|
@ -331,11 +330,10 @@ impl Database {
|
|||
.exec_without_returning(&*tx)
|
||||
.await?;
|
||||
|
||||
if let Ok(db_version) = semver::Version::parse(&extension.latest_version) {
|
||||
if db_version >= latest_version.version {
|
||||
if let Ok(db_version) = semver::Version::parse(&extension.latest_version)
|
||||
&& db_version >= latest_version.version {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
let mut extension = extension.into_active_model();
|
||||
extension.latest_version = ActiveValue::Set(latest_version.version.to_string());
|
||||
|
|
|
@ -1321,11 +1321,10 @@ impl Database {
|
|||
.await?;
|
||||
|
||||
let mut connection_ids = HashSet::default();
|
||||
if let Some(host_connection) = project.host_connection().log_err() {
|
||||
if !exclude_dev_server {
|
||||
if let Some(host_connection) = project.host_connection().log_err()
|
||||
&& !exclude_dev_server {
|
||||
connection_ids.insert(host_connection);
|
||||
}
|
||||
}
|
||||
|
||||
while let Some(collaborator) = collaborators.next().await {
|
||||
let collaborator = collaborator?;
|
||||
|
|
|
@ -616,11 +616,10 @@ impl Server {
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(live_kit) = livekit_client.as_ref() {
|
||||
if delete_livekit_room {
|
||||
if let Some(live_kit) = livekit_client.as_ref()
|
||||
&& delete_livekit_room {
|
||||
live_kit.delete_room(livekit_room).await.trace_err();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1015,8 +1014,8 @@ impl Server {
|
|||
inviter_id: UserId,
|
||||
invitee_id: UserId,
|
||||
) -> Result<()> {
|
||||
if let Some(user) = self.app_state.db.get_user_by_id(inviter_id).await? {
|
||||
if let Some(code) = &user.invite_code {
|
||||
if let Some(user) = self.app_state.db.get_user_by_id(inviter_id).await?
|
||||
&& let Some(code) = &user.invite_code {
|
||||
let pool = self.connection_pool.lock();
|
||||
let invitee_contact = contact_for_user(invitee_id, false, &pool);
|
||||
for connection_id in pool.user_connection_ids(inviter_id) {
|
||||
|
@ -1036,13 +1035,12 @@ impl Server {
|
|||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub async fn invite_count_updated(self: &Arc<Self>, user_id: UserId) -> Result<()> {
|
||||
if let Some(user) = self.app_state.db.get_user_by_id(user_id).await? {
|
||||
if let Some(invite_code) = &user.invite_code {
|
||||
if let Some(user) = self.app_state.db.get_user_by_id(user_id).await?
|
||||
&& let Some(invite_code) = &user.invite_code {
|
||||
let pool = self.connection_pool.lock();
|
||||
for connection_id in pool.user_connection_ids(user_id) {
|
||||
self.peer.send(
|
||||
|
@ -1057,7 +1055,6 @@ impl Server {
|
|||
)?;
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
|
@ -1101,11 +1098,10 @@ fn broadcast<F>(
|
|||
F: FnMut(ConnectionId) -> anyhow::Result<()>,
|
||||
{
|
||||
for receiver_id in receiver_ids {
|
||||
if Some(receiver_id) != sender_id {
|
||||
if let Err(error) = f(receiver_id) {
|
||||
if Some(receiver_id) != sender_id
|
||||
&& let Err(error) = f(receiver_id) {
|
||||
tracing::error!("failed to send to {:?} {}", receiver_id, error);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -2294,12 +2290,10 @@ async fn update_language_server(
|
|||
let db = session.db().await;
|
||||
|
||||
if let Some(proto::update_language_server::Variant::MetadataUpdated(update)) = &request.variant
|
||||
{
|
||||
if let Some(capabilities) = update.capabilities.clone() {
|
||||
&& let Some(capabilities) = update.capabilities.clone() {
|
||||
db.update_server_capabilities(project_id, request.language_server_id, capabilities)
|
||||
.await?;
|
||||
}
|
||||
}
|
||||
|
||||
let project_connection_ids = db
|
||||
.project_connection_ids(project_id, session.connection_id, true)
|
||||
|
|
|
@ -1162,8 +1162,8 @@ impl RandomizedTest for ProjectCollaborationTest {
|
|||
Some((project, cx))
|
||||
});
|
||||
|
||||
if !guest_project.is_disconnected(cx) {
|
||||
if let Some((host_project, host_cx)) = host_project {
|
||||
if !guest_project.is_disconnected(cx)
|
||||
&& let Some((host_project, host_cx)) = host_project {
|
||||
let host_worktree_snapshots =
|
||||
host_project.read_with(host_cx, |host_project, cx| {
|
||||
host_project
|
||||
|
@ -1235,7 +1235,6 @@ impl RandomizedTest for ProjectCollaborationTest {
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
for buffer in guest_project.opened_buffers(cx) {
|
||||
let buffer = buffer.read(cx);
|
||||
|
|
|
@ -198,12 +198,11 @@ pub async fn run_randomized_test<T: RandomizedTest>(
|
|||
}
|
||||
|
||||
pub fn save_randomized_test_plan() {
|
||||
if let Some(serialize_plan) = LAST_PLAN.lock().take() {
|
||||
if let Some(path) = plan_save_path() {
|
||||
if let Some(serialize_plan) = LAST_PLAN.lock().take()
|
||||
&& let Some(path) = plan_save_path() {
|
||||
eprintln!("saved test plan to path {:?}", path);
|
||||
std::fs::write(path, serialize_plan()).unwrap();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
impl<T: RandomizedTest> TestPlan<T> {
|
||||
|
@ -290,11 +289,9 @@ impl<T: RandomizedTest> TestPlan<T> {
|
|||
if let StoredOperation::Client {
|
||||
user_id, batch_id, ..
|
||||
} = operation
|
||||
{
|
||||
if batch_id == current_batch_id {
|
||||
&& batch_id == current_batch_id {
|
||||
return Some(user_id);
|
||||
}
|
||||
}
|
||||
None
|
||||
}));
|
||||
user_ids.sort_unstable();
|
||||
|
@ -366,11 +363,9 @@ impl<T: RandomizedTest> TestPlan<T> {
|
|||
},
|
||||
applied,
|
||||
) = stored_operation
|
||||
{
|
||||
if user_id == ¤t_user_id {
|
||||
&& user_id == ¤t_user_id {
|
||||
return Some((operation.clone(), applied.clone()));
|
||||
}
|
||||
}
|
||||
}
|
||||
None
|
||||
} else {
|
||||
|
@ -550,12 +545,11 @@ impl<T: RandomizedTest> TestPlan<T> {
|
|||
.unwrap();
|
||||
let pool = server.connection_pool.lock();
|
||||
for contact in contacts {
|
||||
if let db::Contact::Accepted { user_id, busy, .. } = contact {
|
||||
if user_id == removed_user_id {
|
||||
if let db::Contact::Accepted { user_id, busy, .. } = contact
|
||||
&& user_id == removed_user_id {
|
||||
assert!(!pool.is_user_online(user_id));
|
||||
assert!(!busy);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
|
|
@ -130,8 +130,8 @@ impl UserBackfiller {
|
|||
.and_then(|value| value.parse::<i64>().ok())
|
||||
.and_then(|value| DateTime::from_timestamp(value, 0));
|
||||
|
||||
if rate_limit_remaining == Some(0) {
|
||||
if let Some(reset_at) = rate_limit_reset {
|
||||
if rate_limit_remaining == Some(0)
|
||||
&& let Some(reset_at) = rate_limit_reset {
|
||||
let now = Utc::now();
|
||||
if reset_at > now {
|
||||
let sleep_duration = reset_at - now;
|
||||
|
@ -142,7 +142,6 @@ impl UserBackfiller {
|
|||
self.executor.sleep(sleep_duration.to_std().unwrap()).await;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
response
|
||||
.error_for_status()
|
||||
|
|
|
@ -107,8 +107,8 @@ impl ChannelView {
|
|||
.find(|view| view.read(cx).channel_buffer.read(cx).remote_id(cx) == buffer_id);
|
||||
|
||||
// If this channel buffer is already open in this pane, just return it.
|
||||
if let Some(existing_view) = existing_view.clone() {
|
||||
if existing_view.read(cx).channel_buffer == channel_view.read(cx).channel_buffer
|
||||
if let Some(existing_view) = existing_view.clone()
|
||||
&& existing_view.read(cx).channel_buffer == channel_view.read(cx).channel_buffer
|
||||
{
|
||||
if let Some(link_position) = link_position {
|
||||
existing_view.update(cx, |channel_view, cx| {
|
||||
|
@ -122,12 +122,11 @@ impl ChannelView {
|
|||
}
|
||||
return existing_view;
|
||||
}
|
||||
}
|
||||
|
||||
// If the pane contained a disconnected view for this channel buffer,
|
||||
// replace that.
|
||||
if let Some(existing_item) = existing_view {
|
||||
if let Some(ix) = pane.index_for_item(&existing_item) {
|
||||
if let Some(existing_item) = existing_view
|
||||
&& let Some(ix) = pane.index_for_item(&existing_item) {
|
||||
pane.close_item_by_id(
|
||||
existing_item.entity_id(),
|
||||
SaveIntent::Skip,
|
||||
|
@ -144,7 +143,6 @@ impl ChannelView {
|
|||
cx,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(link_position) = link_position {
|
||||
channel_view.update(cx, |channel_view, cx| {
|
||||
|
@ -259,8 +257,8 @@ impl ChannelView {
|
|||
.editor
|
||||
.update(cx, |editor, cx| editor.snapshot(window, cx));
|
||||
|
||||
if let Some(outline) = snapshot.buffer_snapshot.outline(None) {
|
||||
if let Some(item) = outline
|
||||
if let Some(outline) = snapshot.buffer_snapshot.outline(None)
|
||||
&& let Some(item) = outline
|
||||
.items
|
||||
.iter()
|
||||
.find(|item| &Channel::slug(&item.text).to_lowercase() == &position)
|
||||
|
@ -279,7 +277,6 @@ impl ChannelView {
|
|||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if !first_attempt {
|
||||
return;
|
||||
|
|
|
@ -287,8 +287,8 @@ impl ChatPanel {
|
|||
}
|
||||
|
||||
fn acknowledge_last_message(&mut self, cx: &mut Context<Self>) {
|
||||
if self.active && self.is_scrolled_to_bottom {
|
||||
if let Some((chat, _)) = &self.active_chat {
|
||||
if self.active && self.is_scrolled_to_bottom
|
||||
&& let Some((chat, _)) = &self.active_chat {
|
||||
if let Some(channel_id) = self.channel_id(cx) {
|
||||
self.last_acknowledged_message_id = self
|
||||
.channel_store
|
||||
|
@ -300,7 +300,6 @@ impl ChatPanel {
|
|||
chat.acknowledge_last_message(cx);
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn render_replied_to_message(
|
||||
|
@ -405,15 +404,14 @@ impl ChatPanel {
|
|||
&& last_message.id != this_message.id
|
||||
&& duration_since_last_message < Duration::from_secs(5 * 60);
|
||||
|
||||
if let ChannelMessageId::Saved(id) = this_message.id {
|
||||
if this_message
|
||||
if let ChannelMessageId::Saved(id) = this_message.id
|
||||
&& this_message
|
||||
.mentions
|
||||
.iter()
|
||||
.any(|(_, user_id)| Some(*user_id) == self.client.user_id())
|
||||
{
|
||||
active_chat.acknowledge_message(id);
|
||||
}
|
||||
}
|
||||
|
||||
(this_message, is_continuation_from_previous, is_admin)
|
||||
});
|
||||
|
@ -871,8 +869,8 @@ impl ChatPanel {
|
|||
scroll_to_message_id.or(this.last_acknowledged_message_id)
|
||||
})?;
|
||||
|
||||
if let Some(message_id) = scroll_to_message_id {
|
||||
if let Some(item_ix) =
|
||||
if let Some(message_id) = scroll_to_message_id
|
||||
&& let Some(item_ix) =
|
||||
ChannelChat::load_history_since_message(chat.clone(), message_id, cx.clone())
|
||||
.await
|
||||
{
|
||||
|
@ -899,7 +897,6 @@ impl ChatPanel {
|
|||
}
|
||||
})?;
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
})
|
||||
|
|
|
@ -241,8 +241,7 @@ impl MessageEditor {
|
|||
) -> Task<Result<Vec<CompletionResponse>>> {
|
||||
if let Some((start_anchor, query, candidates)) =
|
||||
self.collect_mention_candidates(buffer, end_anchor, cx)
|
||||
{
|
||||
if !candidates.is_empty() {
|
||||
&& !candidates.is_empty() {
|
||||
return cx.spawn(async move |_, cx| {
|
||||
let completion_response = Self::completions_for_candidates(
|
||||
cx,
|
||||
|
@ -255,12 +254,10 @@ impl MessageEditor {
|
|||
Ok(vec![completion_response])
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if let Some((start_anchor, query, candidates)) =
|
||||
self.collect_emoji_candidates(buffer, end_anchor, cx)
|
||||
{
|
||||
if !candidates.is_empty() {
|
||||
&& !candidates.is_empty() {
|
||||
return cx.spawn(async move |_, cx| {
|
||||
let completion_response = Self::completions_for_candidates(
|
||||
cx,
|
||||
|
@ -273,7 +270,6 @@ impl MessageEditor {
|
|||
Ok(vec![completion_response])
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
Task::ready(Ok(vec![CompletionResponse {
|
||||
completions: Vec::new(),
|
||||
|
@ -474,8 +470,8 @@ impl MessageEditor {
|
|||
for range in ranges {
|
||||
text.clear();
|
||||
text.extend(buffer.text_for_range(range.clone()));
|
||||
if let Some(username) = text.strip_prefix('@') {
|
||||
if let Some(user) = this
|
||||
if let Some(username) = text.strip_prefix('@')
|
||||
&& let Some(user) = this
|
||||
.user_store
|
||||
.read(cx)
|
||||
.cached_user_by_github_login(username)
|
||||
|
@ -486,7 +482,6 @@ impl MessageEditor {
|
|||
mentioned_user_ids.push(user.id);
|
||||
anchor_ranges.push(start..end);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
editor.clear_highlights::<Self>(cx);
|
||||
|
|
|
@ -311,11 +311,10 @@ impl CollabPanel {
|
|||
window,
|
||||
|this: &mut Self, _, event, window, cx| {
|
||||
if let editor::EditorEvent::Blurred = event {
|
||||
if let Some(state) = &this.channel_editing_state {
|
||||
if state.pending_name().is_some() {
|
||||
if let Some(state) = &this.channel_editing_state
|
||||
&& state.pending_name().is_some() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
this.take_editing_state(window, cx);
|
||||
this.update_entries(false, cx);
|
||||
cx.notify();
|
||||
|
@ -491,12 +490,11 @@ impl CollabPanel {
|
|||
if !self.collapsed_sections.contains(&Section::ActiveCall) {
|
||||
let room = room.read(cx);
|
||||
|
||||
if query.is_empty() {
|
||||
if let Some(channel_id) = room.channel_id() {
|
||||
if query.is_empty()
|
||||
&& let Some(channel_id) = room.channel_id() {
|
||||
self.entries.push(ListEntry::ChannelNotes { channel_id });
|
||||
self.entries.push(ListEntry::ChannelChat { channel_id });
|
||||
}
|
||||
}
|
||||
|
||||
// Populate the active user.
|
||||
if let Some(user) = user_store.current_user() {
|
||||
|
@ -639,11 +637,10 @@ impl CollabPanel {
|
|||
&Default::default(),
|
||||
executor.clone(),
|
||||
));
|
||||
if let Some(state) = &self.channel_editing_state {
|
||||
if matches!(state, ChannelEditingState::Create { location: None, .. }) {
|
||||
if let Some(state) = &self.channel_editing_state
|
||||
&& matches!(state, ChannelEditingState::Create { location: None, .. }) {
|
||||
self.entries.push(ListEntry::ChannelEditor { depth: 0 });
|
||||
}
|
||||
}
|
||||
let mut collapse_depth = None;
|
||||
for mat in matches {
|
||||
let channel = channel_store.channel_at_index(mat.candidate_id).unwrap();
|
||||
|
@ -1552,8 +1549,8 @@ impl CollabPanel {
|
|||
return;
|
||||
}
|
||||
|
||||
if let Some(selection) = self.selection {
|
||||
if let Some(entry) = self.entries.get(selection) {
|
||||
if let Some(selection) = self.selection
|
||||
&& let Some(entry) = self.entries.get(selection) {
|
||||
match entry {
|
||||
ListEntry::Header(section) => match section {
|
||||
Section::ActiveCall => Self::leave_call(window, cx),
|
||||
|
@ -1645,7 +1642,6 @@ impl CollabPanel {
|
|||
ListEntry::ChannelEditor { .. } => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn insert_space(&mut self, _: &InsertSpace, window: &mut Window, cx: &mut Context<Self>) {
|
||||
|
|
|
@ -121,14 +121,13 @@ impl NotificationPanel {
|
|||
let notification_list = ListState::new(0, ListAlignment::Top, px(1000.));
|
||||
notification_list.set_scroll_handler(cx.listener(
|
||||
|this, event: &ListScrollEvent, _, cx| {
|
||||
if event.count.saturating_sub(event.visible_range.end) < LOADING_THRESHOLD {
|
||||
if let Some(task) = this
|
||||
if event.count.saturating_sub(event.visible_range.end) < LOADING_THRESHOLD
|
||||
&& let Some(task) = this
|
||||
.notification_store
|
||||
.update(cx, |store, cx| store.load_more_notifications(false, cx))
|
||||
{
|
||||
task.detach();
|
||||
}
|
||||
}
|
||||
},
|
||||
));
|
||||
|
||||
|
@ -469,8 +468,7 @@ impl NotificationPanel {
|
|||
channel_id,
|
||||
..
|
||||
} = notification.clone()
|
||||
{
|
||||
if let Some(workspace) = self.workspace.upgrade() {
|
||||
&& let Some(workspace) = self.workspace.upgrade() {
|
||||
window.defer(cx, move |window, cx| {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
if let Some(panel) = workspace.focus_panel::<ChatPanel>(window, cx) {
|
||||
|
@ -483,7 +481,6 @@ impl NotificationPanel {
|
|||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn is_showing_notification(&self, notification: &Notification, cx: &mut Context<Self>) -> bool {
|
||||
|
@ -491,8 +488,8 @@ impl NotificationPanel {
|
|||
return false;
|
||||
}
|
||||
|
||||
if let Notification::ChannelMessageMention { channel_id, .. } = ¬ification {
|
||||
if let Some(workspace) = self.workspace.upgrade() {
|
||||
if let Notification::ChannelMessageMention { channel_id, .. } = ¬ification
|
||||
&& let Some(workspace) = self.workspace.upgrade() {
|
||||
return if let Some(panel) = workspace.read(cx).panel::<ChatPanel>(cx) {
|
||||
let panel = panel.read(cx);
|
||||
panel.is_scrolled_to_bottom()
|
||||
|
@ -503,7 +500,6 @@ impl NotificationPanel {
|
|||
false
|
||||
};
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
}
|
||||
|
@ -582,8 +578,8 @@ impl NotificationPanel {
|
|||
}
|
||||
|
||||
fn remove_toast(&mut self, notification_id: u64, cx: &mut Context<Self>) {
|
||||
if let Some((current_id, _)) = &self.current_notification_toast {
|
||||
if *current_id == notification_id {
|
||||
if let Some((current_id, _)) = &self.current_notification_toast
|
||||
&& *current_id == notification_id {
|
||||
self.current_notification_toast.take();
|
||||
self.workspace
|
||||
.update(cx, |workspace, cx| {
|
||||
|
@ -592,7 +588,6 @@ impl NotificationPanel {
|
|||
})
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn respond_to_notification(
|
||||
|
|
|
@ -271,11 +271,10 @@ impl Client {
|
|||
);
|
||||
}
|
||||
} else if let Ok(response) = serde_json::from_str::<AnyResponse>(&message) {
|
||||
if let Some(handlers) = response_handlers.lock().as_mut() {
|
||||
if let Some(handler) = handlers.remove(&response.id) {
|
||||
if let Some(handlers) = response_handlers.lock().as_mut()
|
||||
&& let Some(handler) = handlers.remove(&response.id) {
|
||||
handler(Ok(message.to_string()));
|
||||
}
|
||||
}
|
||||
} else if let Ok(notification) = serde_json::from_str::<AnyNotification>(&message) {
|
||||
let mut notification_handlers = notification_handlers.lock();
|
||||
if let Some(handler) = notification_handlers.get_mut(notification.method.as_str()) {
|
||||
|
|
|
@ -608,8 +608,7 @@ impl Copilot {
|
|||
sign_in_status: status,
|
||||
..
|
||||
}) = &mut this.server
|
||||
{
|
||||
if let SignInStatus::SigningIn {
|
||||
&& let SignInStatus::SigningIn {
|
||||
prompt: prompt_flow,
|
||||
..
|
||||
} = status
|
||||
|
@ -617,7 +616,6 @@ impl Copilot {
|
|||
*prompt_flow = Some(flow.clone());
|
||||
cx.notify();
|
||||
}
|
||||
}
|
||||
})?;
|
||||
let response = lsp
|
||||
.request::<request::SignInConfirm>(
|
||||
|
@ -782,8 +780,8 @@ impl Copilot {
|
|||
event: &language::BufferEvent,
|
||||
cx: &mut Context<Self>,
|
||||
) -> Result<()> {
|
||||
if let Ok(server) = self.server.as_running() {
|
||||
if let Some(registered_buffer) = server.registered_buffers.get_mut(&buffer.entity_id())
|
||||
if let Ok(server) = self.server.as_running()
|
||||
&& let Some(registered_buffer) = server.registered_buffers.get_mut(&buffer.entity_id())
|
||||
{
|
||||
match event {
|
||||
language::BufferEvent::Edited => {
|
||||
|
@ -836,14 +834,13 @@ impl Copilot {
|
|||
_ => {}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
Ok(())
|
||||
}
|
||||
|
||||
fn unregister_buffer(&mut self, buffer: &WeakEntity<Buffer>) {
|
||||
if let Ok(server) = self.server.as_running() {
|
||||
if let Some(buffer) = server.registered_buffers.remove(&buffer.entity_id()) {
|
||||
if let Ok(server) = self.server.as_running()
|
||||
&& let Some(buffer) = server.registered_buffers.remove(&buffer.entity_id()) {
|
||||
server
|
||||
.lsp
|
||||
.notify::<lsp::notification::DidCloseTextDocument>(
|
||||
|
@ -853,7 +850,6 @@ impl Copilot {
|
|||
)
|
||||
.ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn completions<T>(
|
||||
|
|
|
@ -99,11 +99,10 @@ impl JsDebugAdapter {
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(env) = configuration.get("env").cloned() {
|
||||
if let Ok(env) = serde_json::from_value(env) {
|
||||
if let Some(env) = configuration.get("env").cloned()
|
||||
&& let Ok(env) = serde_json::from_value(env) {
|
||||
envs = env;
|
||||
}
|
||||
}
|
||||
|
||||
configuration
|
||||
.entry("cwd")
|
||||
|
|
|
@ -661,12 +661,11 @@ impl ToolbarItemView for DapLogToolbarItemView {
|
|||
_window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) -> workspace::ToolbarItemLocation {
|
||||
if let Some(item) = active_pane_item {
|
||||
if let Some(log_view) = item.downcast::<DapLogView>() {
|
||||
if let Some(item) = active_pane_item
|
||||
&& let Some(log_view) = item.downcast::<DapLogView>() {
|
||||
self.log_view = Some(log_view.clone());
|
||||
return workspace::ToolbarItemLocation::PrimaryLeft;
|
||||
}
|
||||
}
|
||||
self.log_view = None;
|
||||
|
||||
cx.notify();
|
||||
|
|
|
@ -530,11 +530,9 @@ impl DebugPanel {
|
|||
.active_session
|
||||
.as_ref()
|
||||
.map(|session| session.entity_id())
|
||||
{
|
||||
if active_session_id == entity_id {
|
||||
&& active_session_id == entity_id {
|
||||
this.active_session = this.sessions_with_children.keys().next().cloned();
|
||||
}
|
||||
}
|
||||
cx.notify()
|
||||
})
|
||||
.ok();
|
||||
|
@ -1302,11 +1300,10 @@ impl DebugPanel {
|
|||
cx: &mut Context<'_, Self>,
|
||||
) -> Option<SharedString> {
|
||||
let adapter = parent_session.read(cx).adapter();
|
||||
if let Some(adapter) = DapRegistry::global(cx).adapter(&adapter) {
|
||||
if let Some(label) = adapter.label_for_child_session(request) {
|
||||
if let Some(adapter) = DapRegistry::global(cx).adapter(&adapter)
|
||||
&& let Some(label) = adapter.label_for_child_session(request) {
|
||||
return Some(label.into());
|
||||
}
|
||||
}
|
||||
None
|
||||
}
|
||||
|
||||
|
|
|
@ -343,11 +343,10 @@ impl NewProcessModal {
|
|||
return;
|
||||
}
|
||||
|
||||
if let NewProcessMode::Launch = &self.mode {
|
||||
if self.configure_mode.read(cx).save_to_debug_json.selected() {
|
||||
if let NewProcessMode::Launch = &self.mode
|
||||
&& self.configure_mode.read(cx).save_to_debug_json.selected() {
|
||||
self.save_debug_scenario(window, cx);
|
||||
}
|
||||
}
|
||||
|
||||
let Some(debugger) = self.debugger.clone() else {
|
||||
return;
|
||||
|
|
|
@ -239,12 +239,11 @@ impl BreakpointList {
|
|||
}
|
||||
|
||||
fn select_next(&mut self, _: &menu::SelectNext, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if self.strip_mode.is_some() {
|
||||
if self.input.focus_handle(cx).contains_focused(window, cx) {
|
||||
if self.strip_mode.is_some()
|
||||
&& self.input.focus_handle(cx).contains_focused(window, cx) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
let ix = match self.selected_ix {
|
||||
_ if self.breakpoints.len() == 0 => None,
|
||||
None => Some(0),
|
||||
|
@ -265,12 +264,11 @@ impl BreakpointList {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if self.strip_mode.is_some() {
|
||||
if self.input.focus_handle(cx).contains_focused(window, cx) {
|
||||
if self.strip_mode.is_some()
|
||||
&& self.input.focus_handle(cx).contains_focused(window, cx) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
let ix = match self.selected_ix {
|
||||
_ if self.breakpoints.len() == 0 => None,
|
||||
None => Some(self.breakpoints.len() - 1),
|
||||
|
@ -286,12 +284,11 @@ impl BreakpointList {
|
|||
}
|
||||
|
||||
fn select_first(&mut self, _: &menu::SelectFirst, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if self.strip_mode.is_some() {
|
||||
if self.input.focus_handle(cx).contains_focused(window, cx) {
|
||||
if self.strip_mode.is_some()
|
||||
&& self.input.focus_handle(cx).contains_focused(window, cx) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
let ix = if self.breakpoints.len() > 0 {
|
||||
Some(0)
|
||||
} else {
|
||||
|
@ -301,12 +298,11 @@ impl BreakpointList {
|
|||
}
|
||||
|
||||
fn select_last(&mut self, _: &menu::SelectLast, window: &mut Window, cx: &mut Context<Self>) {
|
||||
if self.strip_mode.is_some() {
|
||||
if self.input.focus_handle(cx).contains_focused(window, cx) {
|
||||
if self.strip_mode.is_some()
|
||||
&& self.input.focus_handle(cx).contains_focused(window, cx) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
let ix = if self.breakpoints.len() > 0 {
|
||||
Some(self.breakpoints.len() - 1)
|
||||
} else {
|
||||
|
@ -401,12 +397,11 @@ impl BreakpointList {
|
|||
let Some(entry) = self.selected_ix.and_then(|ix| self.breakpoints.get_mut(ix)) else {
|
||||
return;
|
||||
};
|
||||
if self.strip_mode.is_some() {
|
||||
if self.input.focus_handle(cx).contains_focused(window, cx) {
|
||||
if self.strip_mode.is_some()
|
||||
&& self.input.focus_handle(cx).contains_focused(window, cx) {
|
||||
cx.propagate();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
match &mut entry.kind {
|
||||
BreakpointEntryKind::LineBreakpoint(line_breakpoint) => {
|
||||
|
|
|
@ -611,8 +611,8 @@ impl ConsoleQueryBarCompletionProvider {
|
|||
for variable in console.variable_list.update(cx, |variable_list, cx| {
|
||||
variable_list.completion_variables(cx)
|
||||
}) {
|
||||
if let Some(evaluate_name) = &variable.evaluate_name {
|
||||
if variables
|
||||
if let Some(evaluate_name) = &variable.evaluate_name
|
||||
&& variables
|
||||
.insert(evaluate_name.clone(), variable.value.clone())
|
||||
.is_none()
|
||||
{
|
||||
|
@ -622,7 +622,6 @@ impl ConsoleQueryBarCompletionProvider {
|
|||
char_bag: evaluate_name.chars().collect(),
|
||||
});
|
||||
}
|
||||
}
|
||||
|
||||
if variables
|
||||
.insert(variable.name.clone(), variable.value.clone())
|
||||
|
|
|
@ -639,8 +639,8 @@ impl ProjectDiagnosticsEditor {
|
|||
#[cfg(test)]
|
||||
let cloned_blocks = blocks.clone();
|
||||
|
||||
if was_empty {
|
||||
if let Some(anchor_range) = anchor_ranges.first() {
|
||||
if was_empty
|
||||
&& let Some(anchor_range) = anchor_ranges.first() {
|
||||
let range_to_select = anchor_range.start..anchor_range.start;
|
||||
this.editor.update(cx, |editor, cx| {
|
||||
editor.change_selections(Default::default(), window, cx, |s| {
|
||||
|
@ -651,7 +651,6 @@ impl ProjectDiagnosticsEditor {
|
|||
this.editor.read(cx).focus_handle(cx).focus(window);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let editor_blocks =
|
||||
anchor_ranges
|
||||
|
@ -980,8 +979,7 @@ async fn heuristic_syntactic_expand(
|
|||
// Remove blank lines from start and end
|
||||
if let Some(start_row) = (outline_range.start.row..outline_range.end.row)
|
||||
.find(|row| !snapshot.line_indent_for_row(*row).is_line_blank())
|
||||
{
|
||||
if let Some(end_row) = (outline_range.start.row..outline_range.end.row + 1)
|
||||
&& let Some(end_row) = (outline_range.start.row..outline_range.end.row + 1)
|
||||
.rev()
|
||||
.find(|row| !snapshot.line_indent_for_row(*row).is_line_blank())
|
||||
{
|
||||
|
@ -993,7 +991,6 @@ async fn heuristic_syntactic_expand(
|
|||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut node = snapshot.syntax_ancestor(input_range.clone())?;
|
||||
|
|
|
@ -969,15 +969,14 @@ impl DisplaySnapshot {
|
|||
if let Some(chunk_highlight) = chunk.highlight_style {
|
||||
// For color inlays, blend the color with the editor background
|
||||
let mut processed_highlight = chunk_highlight;
|
||||
if chunk.is_inlay {
|
||||
if let Some(inlay_color) = chunk_highlight.color {
|
||||
if chunk.is_inlay
|
||||
&& let Some(inlay_color) = chunk_highlight.color {
|
||||
// Only blend if the color has transparency (alpha < 1.0)
|
||||
if inlay_color.a < 1.0 {
|
||||
let blended_color = editor_style.background.blend(inlay_color);
|
||||
processed_highlight.color = Some(blended_color);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(highlight_style) = highlight_style.as_mut() {
|
||||
highlight_style.highlight(processed_highlight);
|
||||
|
@ -2351,12 +2350,11 @@ pub mod tests {
|
|||
.highlight_style
|
||||
.and_then(|style| style.color)
|
||||
.map_or(black, |color| color.to_rgb());
|
||||
if let Some((last_chunk, last_severity, last_color)) = chunks.last_mut() {
|
||||
if *last_severity == chunk.diagnostic_severity && *last_color == color {
|
||||
if let Some((last_chunk, last_severity, last_color)) = chunks.last_mut()
|
||||
&& *last_severity == chunk.diagnostic_severity && *last_color == color {
|
||||
last_chunk.push_str(chunk.text);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
|
||||
chunks.push((chunk.text.to_string(), chunk.diagnostic_severity, color));
|
||||
}
|
||||
|
@ -2901,12 +2899,11 @@ pub mod tests {
|
|||
.syntax_highlight_id
|
||||
.and_then(|id| id.style(theme)?.color);
|
||||
let highlight_color = chunk.highlight_style.and_then(|style| style.color);
|
||||
if let Some((last_chunk, last_syntax_color, last_highlight_color)) = chunks.last_mut() {
|
||||
if syntax_color == *last_syntax_color && highlight_color == *last_highlight_color {
|
||||
if let Some((last_chunk, last_syntax_color, last_highlight_color)) = chunks.last_mut()
|
||||
&& syntax_color == *last_syntax_color && highlight_color == *last_highlight_color {
|
||||
last_chunk.push_str(chunk.text);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
chunks.push((chunk.text.to_string(), syntax_color, highlight_color));
|
||||
}
|
||||
chunks
|
||||
|
|
|
@ -525,8 +525,8 @@ impl BlockMap {
|
|||
// * Below blocks that end at the start of the edit
|
||||
// However, if we hit a replace block that ends at the start of the edit we want to reconstruct it.
|
||||
new_transforms.append(cursor.slice(&old_start, Bias::Left), &());
|
||||
if let Some(transform) = cursor.item() {
|
||||
if transform.summary.input_rows > 0
|
||||
if let Some(transform) = cursor.item()
|
||||
&& transform.summary.input_rows > 0
|
||||
&& cursor.end() == old_start
|
||||
&& transform
|
||||
.block
|
||||
|
@ -547,7 +547,6 @@ impl BlockMap {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Ensure the edit starts at a transform boundary.
|
||||
// If the edit starts within an isomorphic transform, preserve its prefix
|
||||
|
@ -657,11 +656,10 @@ impl BlockMap {
|
|||
.iter()
|
||||
.filter_map(|block| {
|
||||
let placement = block.placement.to_wrap_row(wrap_snapshot)?;
|
||||
if let BlockPlacement::Above(row) = placement {
|
||||
if row < new_start {
|
||||
if let BlockPlacement::Above(row) = placement
|
||||
&& row < new_start {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
Some((placement, Block::Custom(block.clone())))
|
||||
}),
|
||||
);
|
||||
|
@ -977,11 +975,10 @@ impl BlockMapReader<'_> {
|
|||
break;
|
||||
}
|
||||
|
||||
if let Some(BlockId::Custom(id)) = transform.block.as_ref().map(|block| block.id()) {
|
||||
if id == block_id {
|
||||
if let Some(BlockId::Custom(id)) = transform.block.as_ref().map(|block| block.id())
|
||||
&& id == block_id {
|
||||
return Some(cursor.start().1);
|
||||
}
|
||||
}
|
||||
cursor.next();
|
||||
}
|
||||
|
||||
|
@ -1299,15 +1296,14 @@ impl BlockSnapshot {
|
|||
|
||||
let mut input_start = transform_input_start;
|
||||
let mut input_end = transform_input_start;
|
||||
if let Some(transform) = cursor.item() {
|
||||
if transform.block.is_none() {
|
||||
if let Some(transform) = cursor.item()
|
||||
&& transform.block.is_none() {
|
||||
input_start += rows.start - transform_output_start;
|
||||
input_end += cmp::min(
|
||||
rows.end - transform_output_start,
|
||||
transform.summary.input_rows,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
BlockChunks {
|
||||
input_chunks: self.wrap_snapshot.chunks(
|
||||
|
@ -1472,8 +1468,8 @@ impl BlockSnapshot {
|
|||
longest_row_chars = summary.longest_row_chars;
|
||||
}
|
||||
|
||||
if let Some(transform) = cursor.item() {
|
||||
if transform.block.is_none() {
|
||||
if let Some(transform) = cursor.item()
|
||||
&& transform.block.is_none() {
|
||||
let Dimensions(output_start, input_start, _) = cursor.start();
|
||||
let overshoot = range.end.0 - output_start.0;
|
||||
let wrap_start_row = input_start.0;
|
||||
|
@ -1485,7 +1481,6 @@ impl BlockSnapshot {
|
|||
longest_row = BlockRow(output_start.0 + summary.longest_row);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
longest_row
|
||||
|
@ -1557,13 +1552,12 @@ impl BlockSnapshot {
|
|||
|
||||
match transform.block.as_ref() {
|
||||
Some(block) => {
|
||||
if block.is_replacement() {
|
||||
if ((bias == Bias::Left || search_left) && output_start <= point.0)
|
||||
|| (!search_left && output_start >= point.0)
|
||||
if block.is_replacement()
|
||||
&& (((bias == Bias::Left || search_left) && output_start <= point.0)
|
||||
|| (!search_left && output_start >= point.0))
|
||||
{
|
||||
return BlockPoint(output_start);
|
||||
}
|
||||
}
|
||||
}
|
||||
None => {
|
||||
let input_point = if point.row >= output_end_row.0 {
|
||||
|
@ -3228,8 +3222,7 @@ mod tests {
|
|||
let mut is_in_replace_block = false;
|
||||
if let Some((BlockPlacement::Replace(replace_range), block)) =
|
||||
sorted_blocks_iter.peek()
|
||||
{
|
||||
if wrap_row >= replace_range.start().0 {
|
||||
&& wrap_row >= replace_range.start().0 {
|
||||
is_in_replace_block = true;
|
||||
|
||||
if wrap_row == replace_range.start().0 {
|
||||
|
@ -3257,7 +3250,6 @@ mod tests {
|
|||
sorted_blocks_iter.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if is_in_replace_block {
|
||||
expected_replaced_buffer_rows.insert(MultiBufferRow(multibuffer_row));
|
||||
|
|
|
@ -289,8 +289,8 @@ impl FoldMapWriter<'_> {
|
|||
let ChunkRendererId::Fold(id) = id else {
|
||||
continue;
|
||||
};
|
||||
if let Some(metadata) = self.0.snapshot.fold_metadata_by_id.get(&id).cloned() {
|
||||
if Some(new_width) != metadata.width {
|
||||
if let Some(metadata) = self.0.snapshot.fold_metadata_by_id.get(&id).cloned()
|
||||
&& Some(new_width) != metadata.width {
|
||||
let buffer_start = metadata.range.start.to_offset(buffer);
|
||||
let buffer_end = metadata.range.end.to_offset(buffer);
|
||||
let inlay_range = inlay_snapshot.to_inlay_offset(buffer_start)
|
||||
|
@ -308,7 +308,6 @@ impl FoldMapWriter<'_> {
|
|||
},
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let edits = consolidate_inlay_edits(edits);
|
||||
|
@ -417,8 +416,8 @@ impl FoldMap {
|
|||
cursor.seek(&InlayOffset(0), Bias::Right);
|
||||
|
||||
while let Some(mut edit) = inlay_edits_iter.next() {
|
||||
if let Some(item) = cursor.item() {
|
||||
if !item.is_fold() {
|
||||
if let Some(item) = cursor.item()
|
||||
&& !item.is_fold() {
|
||||
new_transforms.update_last(
|
||||
|transform| {
|
||||
if !transform.is_fold() {
|
||||
|
@ -429,7 +428,6 @@ impl FoldMap {
|
|||
&(),
|
||||
);
|
||||
}
|
||||
}
|
||||
new_transforms.append(cursor.slice(&edit.old.start, Bias::Left), &());
|
||||
edit.new.start -= edit.old.start - *cursor.start();
|
||||
edit.old.start = *cursor.start();
|
||||
|
|
|
@ -557,12 +557,11 @@ impl InlayMap {
|
|||
let mut buffer_edits_iter = buffer_edits.iter().peekable();
|
||||
while let Some(buffer_edit) = buffer_edits_iter.next() {
|
||||
new_transforms.append(cursor.slice(&buffer_edit.old.start, Bias::Left), &());
|
||||
if let Some(Transform::Isomorphic(transform)) = cursor.item() {
|
||||
if cursor.end().0 == buffer_edit.old.start {
|
||||
if let Some(Transform::Isomorphic(transform)) = cursor.item()
|
||||
&& cursor.end().0 == buffer_edit.old.start {
|
||||
push_isomorphic(&mut new_transforms, *transform);
|
||||
cursor.next();
|
||||
}
|
||||
}
|
||||
|
||||
// Remove all the inlays and transforms contained by the edit.
|
||||
let old_start =
|
||||
|
|
|
@ -249,8 +249,8 @@ impl WrapMap {
|
|||
return;
|
||||
}
|
||||
|
||||
if let Some(wrap_width) = self.wrap_width {
|
||||
if self.background_task.is_none() {
|
||||
if let Some(wrap_width) = self.wrap_width
|
||||
&& self.background_task.is_none() {
|
||||
let pending_edits = self.pending_edits.clone();
|
||||
let mut snapshot = self.snapshot.clone();
|
||||
let text_system = cx.text_system().clone();
|
||||
|
@ -293,7 +293,6 @@ impl WrapMap {
|
|||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let was_interpolated = self.snapshot.interpolated;
|
||||
let mut to_remove_len = 0;
|
||||
|
@ -1065,13 +1064,12 @@ impl sum_tree::Item for Transform {
|
|||
}
|
||||
|
||||
fn push_isomorphic(transforms: &mut Vec<Transform>, summary: TextSummary) {
|
||||
if let Some(last_transform) = transforms.last_mut() {
|
||||
if last_transform.is_isomorphic() {
|
||||
if let Some(last_transform) = transforms.last_mut()
|
||||
&& last_transform.is_isomorphic() {
|
||||
last_transform.summary.input += &summary;
|
||||
last_transform.summary.output += &summary;
|
||||
return;
|
||||
}
|
||||
}
|
||||
transforms.push(Transform::isomorphic(summary));
|
||||
}
|
||||
|
||||
|
|
|
@ -942,11 +942,10 @@ impl ChangeList {
|
|||
}
|
||||
|
||||
pub fn invert_last_group(&mut self) {
|
||||
if let Some(last) = self.changes.last_mut() {
|
||||
if let Some(current) = last.current.as_mut() {
|
||||
if let Some(last) = self.changes.last_mut()
|
||||
&& let Some(current) = last.current.as_mut() {
|
||||
mem::swap(&mut last.original, current);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -1861,8 +1860,8 @@ impl Editor {
|
|||
.then(|| language_settings::SoftWrap::None);
|
||||
|
||||
let mut project_subscriptions = Vec::new();
|
||||
if full_mode {
|
||||
if let Some(project) = project.as_ref() {
|
||||
if full_mode
|
||||
&& let Some(project) = project.as_ref() {
|
||||
project_subscriptions.push(cx.subscribe_in(
|
||||
project,
|
||||
window,
|
||||
|
@ -1969,7 +1968,6 @@ impl Editor {
|
|||
}
|
||||
}));
|
||||
}
|
||||
}
|
||||
|
||||
let buffer_snapshot = buffer.read(cx).snapshot(cx);
|
||||
|
||||
|
@ -2323,8 +2321,8 @@ impl Editor {
|
|||
|
||||
editor.go_to_active_debug_line(window, cx);
|
||||
|
||||
if let Some(buffer) = buffer.read(cx).as_singleton() {
|
||||
if let Some(project) = editor.project() {
|
||||
if let Some(buffer) = buffer.read(cx).as_singleton()
|
||||
&& let Some(project) = editor.project() {
|
||||
let handle = project.update(cx, |project, cx| {
|
||||
project.register_buffer_with_language_servers(&buffer, cx)
|
||||
});
|
||||
|
@ -2332,7 +2330,6 @@ impl Editor {
|
|||
.registered_buffers
|
||||
.insert(buffer.read(cx).remote_id(), handle);
|
||||
}
|
||||
}
|
||||
|
||||
editor.minimap =
|
||||
editor.create_minimap(EditorSettings::get_global(cx).minimap, window, cx);
|
||||
|
@ -3035,9 +3032,9 @@ impl Editor {
|
|||
}
|
||||
|
||||
if local {
|
||||
if let Some(buffer_id) = new_cursor_position.buffer_id {
|
||||
if !self.registered_buffers.contains_key(&buffer_id) {
|
||||
if let Some(project) = self.project.as_ref() {
|
||||
if let Some(buffer_id) = new_cursor_position.buffer_id
|
||||
&& !self.registered_buffers.contains_key(&buffer_id)
|
||||
&& let Some(project) = self.project.as_ref() {
|
||||
project.update(cx, |project, cx| {
|
||||
let Some(buffer) = self.buffer.read(cx).buffer(buffer_id) else {
|
||||
return;
|
||||
|
@ -3048,8 +3045,6 @@ impl Editor {
|
|||
);
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut context_menu = self.context_menu.borrow_mut();
|
||||
let completion_menu = match context_menu.as_ref() {
|
||||
|
@ -3063,8 +3058,8 @@ impl Editor {
|
|||
let completion_position = completion_menu.map(|menu| menu.initial_position);
|
||||
drop(context_menu);
|
||||
|
||||
if effects.completions {
|
||||
if let Some(completion_position) = completion_position {
|
||||
if effects.completions
|
||||
&& let Some(completion_position) = completion_position {
|
||||
let start_offset = selection_start.to_offset(buffer);
|
||||
let position_matches = start_offset == completion_position.to_offset(buffer);
|
||||
let continue_showing = if position_matches {
|
||||
|
@ -3086,7 +3081,6 @@ impl Editor {
|
|||
self.hide_context_menu(window, cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
hide_hover(self, cx);
|
||||
|
||||
|
@ -3115,8 +3109,8 @@ impl Editor {
|
|||
if selections.len() == 1 {
|
||||
cx.emit(SearchEvent::ActiveMatchChanged)
|
||||
}
|
||||
if local {
|
||||
if let Some((_, _, buffer_snapshot)) = buffer.as_singleton() {
|
||||
if local
|
||||
&& let Some((_, _, buffer_snapshot)) = buffer.as_singleton() {
|
||||
let inmemory_selections = selections
|
||||
.iter()
|
||||
.map(|s| {
|
||||
|
@ -3130,8 +3124,7 @@ impl Editor {
|
|||
|
||||
if WorkspaceSettings::get(None, cx).restore_on_startup
|
||||
!= RestoreOnStartupBehavior::None
|
||||
{
|
||||
if let Some(workspace_id) =
|
||||
&& let Some(workspace_id) =
|
||||
self.workspace.as_ref().and_then(|workspace| workspace.1)
|
||||
{
|
||||
let snapshot = self.buffer().read(cx).snapshot(cx);
|
||||
|
@ -3156,9 +3149,7 @@ impl Editor {
|
|||
.log_err();
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
cx.notify();
|
||||
}
|
||||
|
@ -4154,12 +4145,10 @@ impl Editor {
|
|||
if self.auto_replace_emoji_shortcode
|
||||
&& selection.is_empty()
|
||||
&& text.as_ref().ends_with(':')
|
||||
{
|
||||
if let Some(possible_emoji_short_code) =
|
||||
&& let Some(possible_emoji_short_code) =
|
||||
Self::find_possible_emoji_shortcode_at_position(&snapshot, selection.start)
|
||||
{
|
||||
if !possible_emoji_short_code.is_empty() {
|
||||
if let Some(emoji) = emojis::get_by_shortcode(&possible_emoji_short_code) {
|
||||
&& !possible_emoji_short_code.is_empty()
|
||||
&& let Some(emoji) = emojis::get_by_shortcode(&possible_emoji_short_code) {
|
||||
let emoji_shortcode_start = Point::new(
|
||||
selection.start.row,
|
||||
selection.start.column - possible_emoji_short_code.len() as u32 - 1,
|
||||
|
@ -4188,9 +4177,6 @@ impl Editor {
|
|||
|
||||
continue;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// If not handling any auto-close operation, then just replace the selected
|
||||
// text with the given input and move the selection to the end of the
|
||||
|
@ -4303,13 +4289,12 @@ impl Editor {
|
|||
|s| s.select(new_selections),
|
||||
);
|
||||
|
||||
if !bracket_inserted {
|
||||
if let Some(on_type_format_task) =
|
||||
if !bracket_inserted
|
||||
&& let Some(on_type_format_task) =
|
||||
this.trigger_on_type_formatting(text.to_string(), window, cx)
|
||||
{
|
||||
on_type_format_task.detach_and_log_err(cx);
|
||||
}
|
||||
}
|
||||
|
||||
let editor_settings = EditorSettings::get_global(cx);
|
||||
if bracket_inserted
|
||||
|
@ -5274,11 +5259,10 @@ impl Editor {
|
|||
}
|
||||
|
||||
let language = buffer.language()?;
|
||||
if let Some(restrict_to_languages) = restrict_to_languages {
|
||||
if !restrict_to_languages.contains(language) {
|
||||
if let Some(restrict_to_languages) = restrict_to_languages
|
||||
&& !restrict_to_languages.contains(language) {
|
||||
return None;
|
||||
}
|
||||
}
|
||||
Some((
|
||||
excerpt_id,
|
||||
(
|
||||
|
@ -5605,8 +5589,8 @@ impl Editor {
|
|||
// that having one source with `is_incomplete: true` doesn't cause all to be re-queried.
|
||||
let mut completions = Vec::new();
|
||||
let mut is_incomplete = false;
|
||||
if let Some(provider_responses) = provider_responses.await.log_err() {
|
||||
if !provider_responses.is_empty() {
|
||||
if let Some(provider_responses) = provider_responses.await.log_err()
|
||||
&& !provider_responses.is_empty() {
|
||||
for response in provider_responses {
|
||||
completions.extend(response.completions);
|
||||
is_incomplete = is_incomplete || response.is_incomplete;
|
||||
|
@ -5615,7 +5599,6 @@ impl Editor {
|
|||
words = Task::ready(BTreeMap::default());
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let mut words = words.await;
|
||||
if let Some(word_to_exclude) = &word_to_exclude {
|
||||
|
@ -5718,8 +5701,8 @@ impl Editor {
|
|||
|
||||
editor
|
||||
.update_in(cx, |editor, window, cx| {
|
||||
if editor.focus_handle.is_focused(window) {
|
||||
if let Some(menu) = menu {
|
||||
if editor.focus_handle.is_focused(window)
|
||||
&& let Some(menu) = menu {
|
||||
*editor.context_menu.borrow_mut() =
|
||||
Some(CodeContextMenu::Completions(menu));
|
||||
|
||||
|
@ -5733,7 +5716,6 @@ impl Editor {
|
|||
cx.notify();
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if editor.completion_tasks.len() <= 1 {
|
||||
// If there are no more completion tasks and the last menu was empty, we should hide it.
|
||||
|
@ -6079,12 +6061,11 @@ impl Editor {
|
|||
Some(CodeActionSource::Indicator(_)) => Task::ready(Ok(Default::default())),
|
||||
_ => {
|
||||
let mut task_context_task = Task::ready(None);
|
||||
if let Some(tasks) = &tasks {
|
||||
if let Some(project) = project {
|
||||
if let Some(tasks) = &tasks
|
||||
&& let Some(project) = project {
|
||||
task_context_task =
|
||||
Self::build_tasks_context(&project, &buffer, buffer_row, tasks, cx);
|
||||
}
|
||||
}
|
||||
|
||||
cx.spawn_in(window, {
|
||||
let buffer = buffer.clone();
|
||||
|
@ -6148,15 +6129,14 @@ impl Editor {
|
|||
deployed_from,
|
||||
}));
|
||||
cx.notify();
|
||||
if spawn_straight_away {
|
||||
if let Some(task) = editor.confirm_code_action(
|
||||
if spawn_straight_away
|
||||
&& let Some(task) = editor.confirm_code_action(
|
||||
&ConfirmCodeAction { item_ix: Some(0) },
|
||||
window,
|
||||
cx,
|
||||
) {
|
||||
return task;
|
||||
}
|
||||
}
|
||||
|
||||
Task::ready(Ok(()))
|
||||
})
|
||||
|
@ -6342,8 +6322,8 @@ impl Editor {
|
|||
.read(cx)
|
||||
.excerpt_containing(editor.selections.newest_anchor().head(), cx)
|
||||
})?;
|
||||
if let Some((_, excerpted_buffer, excerpt_range)) = excerpt {
|
||||
if excerpted_buffer == *buffer {
|
||||
if let Some((_, excerpted_buffer, excerpt_range)) = excerpt
|
||||
&& excerpted_buffer == *buffer {
|
||||
let all_edits_within_excerpt = buffer.read_with(cx, |buffer, _| {
|
||||
let excerpt_range = excerpt_range.to_offset(buffer);
|
||||
buffer
|
||||
|
@ -6358,7 +6338,6 @@ impl Editor {
|
|||
return Ok(());
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
} else {
|
||||
return Ok(());
|
||||
|
@ -7779,11 +7758,10 @@ impl Editor {
|
|||
|
||||
let indents = multibuffer.suggested_indents(cursor_point.row..cursor_point.row + 1, cx);
|
||||
|
||||
if let Some((_, indent)) = indents.iter().next() {
|
||||
if indent.len == cursor_point.column {
|
||||
if let Some((_, indent)) = indents.iter().next()
|
||||
&& indent.len == cursor_point.column {
|
||||
self.edit_prediction_indent_conflict = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let edit_prediction = provider.suggest(&buffer, cursor_buffer_position, cx)?;
|
||||
|
@ -9531,11 +9509,10 @@ impl Editor {
|
|||
let context_menu = self.context_menu.borrow_mut().take();
|
||||
self.stale_edit_prediction_in_menu.take();
|
||||
self.update_visible_edit_prediction(window, cx);
|
||||
if let Some(CodeContextMenu::Completions(_)) = &context_menu {
|
||||
if let Some(completion_provider) = &self.completion_provider {
|
||||
if let Some(CodeContextMenu::Completions(_)) = &context_menu
|
||||
&& let Some(completion_provider) = &self.completion_provider {
|
||||
completion_provider.selection_changed(None, window, cx);
|
||||
}
|
||||
}
|
||||
context_menu
|
||||
}
|
||||
|
||||
|
@ -9639,11 +9616,10 @@ impl Editor {
|
|||
s.select_ranges(tabstop.ranges.iter().rev().cloned());
|
||||
});
|
||||
|
||||
if let Some(choices) = &tabstop.choices {
|
||||
if let Some(selection) = tabstop.ranges.first() {
|
||||
if let Some(choices) = &tabstop.choices
|
||||
&& let Some(selection) = tabstop.ranges.first() {
|
||||
self.show_snippet_choices(choices, selection.clone(), cx)
|
||||
}
|
||||
}
|
||||
|
||||
// If we're already at the last tabstop and it's at the end of the snippet,
|
||||
// we're done, we don't need to keep the state around.
|
||||
|
@ -9776,11 +9752,10 @@ impl Editor {
|
|||
s.select_ranges(current_ranges.iter().rev().cloned())
|
||||
});
|
||||
|
||||
if let Some(choices) = &snippet.choices[snippet.active_index] {
|
||||
if let Some(selection) = current_ranges.first() {
|
||||
if let Some(choices) = &snippet.choices[snippet.active_index]
|
||||
&& let Some(selection) = current_ranges.first() {
|
||||
self.show_snippet_choices(choices, selection.clone(), cx);
|
||||
}
|
||||
}
|
||||
|
||||
// If snippet state is not at the last tabstop, push it back on the stack
|
||||
if snippet.active_index + 1 < snippet.ranges.len() {
|
||||
|
@ -10176,11 +10151,10 @@ impl Editor {
|
|||
|
||||
// Avoid re-outdenting a row that has already been outdented by a
|
||||
// previous selection.
|
||||
if let Some(last_row) = last_outdent {
|
||||
if last_row == rows.start {
|
||||
if let Some(last_row) = last_outdent
|
||||
&& last_row == rows.start {
|
||||
rows.start = rows.start.next_row();
|
||||
}
|
||||
}
|
||||
let has_multiple_rows = rows.len() > 1;
|
||||
for row in rows.iter_rows() {
|
||||
let indent_size = snapshot.indent_size_for_line(row);
|
||||
|
@ -10357,12 +10331,11 @@ impl Editor {
|
|||
MultiBufferRow(selection.end.row)
|
||||
};
|
||||
|
||||
if let Some(last_row_range) = row_ranges.last_mut() {
|
||||
if start <= last_row_range.end {
|
||||
if let Some(last_row_range) = row_ranges.last_mut()
|
||||
&& start <= last_row_range.end {
|
||||
last_row_range.end = end;
|
||||
continue;
|
||||
}
|
||||
}
|
||||
row_ranges.push(start..end);
|
||||
}
|
||||
|
||||
|
@ -15331,9 +15304,9 @@ impl Editor {
|
|||
if direction == ExpandExcerptDirection::Down {
|
||||
let multi_buffer = self.buffer.read(cx);
|
||||
let snapshot = multi_buffer.snapshot(cx);
|
||||
if let Some(buffer_id) = snapshot.buffer_id_for_excerpt(excerpt) {
|
||||
if let Some(buffer) = multi_buffer.buffer(buffer_id) {
|
||||
if let Some(excerpt_range) = snapshot.buffer_range_for_excerpt(excerpt) {
|
||||
if let Some(buffer_id) = snapshot.buffer_id_for_excerpt(excerpt)
|
||||
&& let Some(buffer) = multi_buffer.buffer(buffer_id)
|
||||
&& let Some(excerpt_range) = snapshot.buffer_range_for_excerpt(excerpt) {
|
||||
let buffer_snapshot = buffer.read(cx).snapshot();
|
||||
let excerpt_end_row =
|
||||
Point::from_anchor(&excerpt_range.end, &buffer_snapshot).row;
|
||||
|
@ -15341,8 +15314,6 @@ impl Editor {
|
|||
let lines_below = last_row.saturating_sub(excerpt_end_row);
|
||||
should_scroll_up = lines_below >= lines_to_expand;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
self.buffer.update(cx, |buffer, cx| {
|
||||
|
@ -15426,11 +15397,10 @@ impl Editor {
|
|||
let selection = self.selections.newest::<usize>(cx);
|
||||
|
||||
let mut active_group_id = None;
|
||||
if let ActiveDiagnostic::Group(active_group) = &self.active_diagnostics {
|
||||
if active_group.active_range.start.to_offset(&buffer) == selection.start {
|
||||
if let ActiveDiagnostic::Group(active_group) = &self.active_diagnostics
|
||||
&& active_group.active_range.start.to_offset(&buffer) == selection.start {
|
||||
active_group_id = Some(active_group.group_id);
|
||||
}
|
||||
}
|
||||
|
||||
fn filtered(
|
||||
snapshot: EditorSnapshot,
|
||||
|
@ -16674,11 +16644,10 @@ impl Editor {
|
|||
|
||||
buffer
|
||||
.update(cx, |buffer, cx| {
|
||||
if let Some(transaction) = transaction {
|
||||
if !buffer.is_singleton() {
|
||||
if let Some(transaction) = transaction
|
||||
&& !buffer.is_singleton() {
|
||||
buffer.push_transaction(&transaction.0, cx);
|
||||
}
|
||||
}
|
||||
cx.notify();
|
||||
})
|
||||
.ok();
|
||||
|
@ -16743,11 +16712,10 @@ impl Editor {
|
|||
buffer
|
||||
.update(cx, |buffer, cx| {
|
||||
// check if we need this
|
||||
if let Some(transaction) = transaction {
|
||||
if !buffer.is_singleton() {
|
||||
if let Some(transaction) = transaction
|
||||
&& !buffer.is_singleton() {
|
||||
buffer.push_transaction(&transaction.0, cx);
|
||||
}
|
||||
}
|
||||
cx.notify();
|
||||
})
|
||||
.ok();
|
||||
|
@ -17378,14 +17346,13 @@ impl Editor {
|
|||
}
|
||||
|
||||
for row in (0..=range.start.row).rev() {
|
||||
if let Some(crease) = display_map.crease_for_buffer_row(MultiBufferRow(row)) {
|
||||
if crease.range().end.row >= buffer_start_row {
|
||||
if let Some(crease) = display_map.crease_for_buffer_row(MultiBufferRow(row))
|
||||
&& crease.range().end.row >= buffer_start_row {
|
||||
to_fold.push(crease);
|
||||
if row <= range.start.row {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -18693,11 +18660,10 @@ impl Editor {
|
|||
|
||||
pub fn working_directory(&self, cx: &App) -> Option<PathBuf> {
|
||||
if let Some(buffer) = self.buffer().read(cx).as_singleton() {
|
||||
if let Some(file) = buffer.read(cx).file().and_then(|f| f.as_local()) {
|
||||
if let Some(dir) = file.abs_path(cx).parent() {
|
||||
if let Some(file) = buffer.read(cx).file().and_then(|f| f.as_local())
|
||||
&& let Some(dir) = file.abs_path(cx).parent() {
|
||||
return Some(dir.to_owned());
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(project_path) = buffer.read(cx).project_path(cx) {
|
||||
return Some(project_path.path.to_path_buf());
|
||||
|
@ -18756,11 +18722,10 @@ impl Editor {
|
|||
_window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if let Some(path) = self.target_file_abs_path(cx) {
|
||||
if let Some(path) = path.to_str() {
|
||||
if let Some(path) = self.target_file_abs_path(cx)
|
||||
&& let Some(path) = path.to_str() {
|
||||
cx.write_to_clipboard(ClipboardItem::new_string(path.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn copy_relative_path(
|
||||
|
@ -18769,11 +18734,10 @@ impl Editor {
|
|||
_window: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if let Some(path) = self.target_file_path(cx) {
|
||||
if let Some(path) = path.to_str() {
|
||||
if let Some(path) = self.target_file_path(cx)
|
||||
&& let Some(path) = path.to_str() {
|
||||
cx.write_to_clipboard(ClipboardItem::new_string(path.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn project_path(&self, cx: &App) -> Option<ProjectPath> {
|
||||
|
@ -18841,23 +18805,19 @@ impl Editor {
|
|||
_: &mut Window,
|
||||
cx: &mut Context<Self>,
|
||||
) {
|
||||
if let Some(file) = self.target_file(cx) {
|
||||
if let Some(file_stem) = file.path().file_stem() {
|
||||
if let Some(name) = file_stem.to_str() {
|
||||
if let Some(file) = self.target_file(cx)
|
||||
&& let Some(file_stem) = file.path().file_stem()
|
||||
&& let Some(name) = file_stem.to_str() {
|
||||
cx.write_to_clipboard(ClipboardItem::new_string(name.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn copy_file_name(&mut self, _: &CopyFileName, _: &mut Window, cx: &mut Context<Self>) {
|
||||
if let Some(file) = self.target_file(cx) {
|
||||
if let Some(file_name) = file.path().file_name() {
|
||||
if let Some(name) = file_name.to_str() {
|
||||
if let Some(file) = self.target_file(cx)
|
||||
&& let Some(file_name) = file.path().file_name()
|
||||
&& let Some(name) = file_name.to_str() {
|
||||
cx.write_to_clipboard(ClipboardItem::new_string(name.to_string()));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn toggle_git_blame(
|
||||
|
@ -19126,11 +19086,10 @@ impl Editor {
|
|||
cx: &mut Context<Self>,
|
||||
) {
|
||||
let selection = self.selections.newest::<Point>(cx).start.row + 1;
|
||||
if let Some(file) = self.target_file(cx) {
|
||||
if let Some(path) = file.path().to_str() {
|
||||
if let Some(file) = self.target_file(cx)
|
||||
&& let Some(path) = file.path().to_str() {
|
||||
cx.write_to_clipboard(ClipboardItem::new_string(format!("{path}:{selection}")));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
pub fn open_permalink_to_line(
|
||||
|
@ -19769,11 +19728,10 @@ impl Editor {
|
|||
break;
|
||||
}
|
||||
let end = range.end.to_point(&display_snapshot.buffer_snapshot);
|
||||
if let Some(current_row) = &end_row {
|
||||
if end.row == current_row.row {
|
||||
if let Some(current_row) = &end_row
|
||||
&& end.row == current_row.row {
|
||||
continue;
|
||||
}
|
||||
}
|
||||
let start = range.start.to_point(&display_snapshot.buffer_snapshot);
|
||||
if start_row.is_none() {
|
||||
assert_eq!(end_row, None);
|
||||
|
@ -20064,8 +20022,8 @@ impl Editor {
|
|||
if self.has_active_edit_prediction() {
|
||||
self.update_visible_edit_prediction(window, cx);
|
||||
}
|
||||
if let Some(project) = self.project.as_ref() {
|
||||
if let Some(edited_buffer) = edited_buffer {
|
||||
if let Some(project) = self.project.as_ref()
|
||||
&& let Some(edited_buffer) = edited_buffer {
|
||||
project.update(cx, |project, cx| {
|
||||
self.registered_buffers
|
||||
.entry(edited_buffer.read(cx).remote_id())
|
||||
|
@ -20074,7 +20032,6 @@ impl Editor {
|
|||
});
|
||||
});
|
||||
}
|
||||
}
|
||||
cx.emit(EditorEvent::BufferEdited);
|
||||
cx.emit(SearchEvent::MatchesInvalidated);
|
||||
|
||||
|
@ -20083,11 +20040,10 @@ impl Editor {
|
|||
}
|
||||
|
||||
if *singleton_buffer_edited {
|
||||
if let Some(buffer) = edited_buffer {
|
||||
if buffer.read(cx).file().is_none() {
|
||||
if let Some(buffer) = edited_buffer
|
||||
&& buffer.read(cx).file().is_none() {
|
||||
cx.emit(EditorEvent::TitleChanged);
|
||||
}
|
||||
}
|
||||
if let Some(project) = &self.project {
|
||||
#[allow(clippy::mutable_key_type)]
|
||||
let languages_affected = multibuffer.update(cx, |multibuffer, cx| {
|
||||
|
@ -20132,8 +20088,8 @@ impl Editor {
|
|||
} => {
|
||||
self.tasks_update_task = Some(self.refresh_runnables(window, cx));
|
||||
let buffer_id = buffer.read(cx).remote_id();
|
||||
if self.buffer.read(cx).diff_for(buffer_id).is_none() {
|
||||
if let Some(project) = &self.project {
|
||||
if self.buffer.read(cx).diff_for(buffer_id).is_none()
|
||||
&& let Some(project) = &self.project {
|
||||
update_uncommitted_diff_for_buffer(
|
||||
cx.entity(),
|
||||
project,
|
||||
|
@ -20143,7 +20099,6 @@ impl Editor {
|
|||
)
|
||||
.detach();
|
||||
}
|
||||
}
|
||||
self.update_lsp_data(false, Some(buffer_id), window, cx);
|
||||
cx.emit(EditorEvent::ExcerptsAdded {
|
||||
buffer: buffer.clone(),
|
||||
|
@ -20746,12 +20701,11 @@ impl Editor {
|
|||
let mut chunk_lines = chunk.text.split('\n').peekable();
|
||||
while let Some(text) = chunk_lines.next() {
|
||||
let mut merged_with_last_token = false;
|
||||
if let Some(last_token) = line.back_mut() {
|
||||
if last_token.highlight == highlight {
|
||||
if let Some(last_token) = line.back_mut()
|
||||
&& last_token.highlight == highlight {
|
||||
last_token.text.push_str(text);
|
||||
merged_with_last_token = true;
|
||||
}
|
||||
}
|
||||
|
||||
if !merged_with_last_token {
|
||||
line.push_back(Chunk {
|
||||
|
@ -21209,8 +21163,8 @@ impl Editor {
|
|||
{
|
||||
let buffer_snapshot = OnceCell::new();
|
||||
|
||||
if let Some(folds) = DB.get_editor_folds(item_id, workspace_id).log_err() {
|
||||
if !folds.is_empty() {
|
||||
if let Some(folds) = DB.get_editor_folds(item_id, workspace_id).log_err()
|
||||
&& !folds.is_empty() {
|
||||
let snapshot =
|
||||
buffer_snapshot.get_or_init(|| self.buffer.read(cx).snapshot(cx));
|
||||
self.fold_ranges(
|
||||
|
@ -21226,10 +21180,9 @@ impl Editor {
|
|||
cx,
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(selections) = DB.get_editor_selections(item_id, workspace_id).log_err() {
|
||||
if !selections.is_empty() {
|
||||
if let Some(selections) = DB.get_editor_selections(item_id, workspace_id).log_err()
|
||||
&& !selections.is_empty() {
|
||||
let snapshot =
|
||||
buffer_snapshot.get_or_init(|| self.buffer.read(cx).snapshot(cx));
|
||||
// skip adding the initial selection to selection history
|
||||
|
@ -21241,8 +21194,7 @@ impl Editor {
|
|||
}));
|
||||
});
|
||||
self.selection_history.mode = SelectionHistoryMode::Normal;
|
||||
}
|
||||
};
|
||||
};
|
||||
}
|
||||
|
||||
self.read_scroll_position_from_db(item_id, workspace_id, window, cx);
|
||||
|
@ -21283,18 +21235,15 @@ fn process_completion_for_edit(
|
|||
let mut snippet_source = completion.new_text.clone();
|
||||
let mut previous_point = text::ToPoint::to_point(cursor_position, buffer);
|
||||
previous_point.column = previous_point.column.saturating_sub(1);
|
||||
if let Some(scope) = buffer_snapshot.language_scope_at(previous_point) {
|
||||
if scope.prefers_label_for_snippet_in_completion() {
|
||||
if let Some(label) = completion.label() {
|
||||
if matches!(
|
||||
if let Some(scope) = buffer_snapshot.language_scope_at(previous_point)
|
||||
&& scope.prefers_label_for_snippet_in_completion()
|
||||
&& let Some(label) = completion.label()
|
||||
&& matches!(
|
||||
completion.kind(),
|
||||
Some(CompletionItemKind::FUNCTION) | Some(CompletionItemKind::METHOD)
|
||||
) {
|
||||
snippet_source = label;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
match Snippet::parse(&snippet_source).log_err() {
|
||||
Some(parsed_snippet) => (Some(parsed_snippet.clone()), parsed_snippet.text),
|
||||
None => (None, completion.new_text.clone()),
|
||||
|
@ -21347,11 +21296,10 @@ fn process_completion_for_edit(
|
|||
);
|
||||
let mut current_needle = text_to_replace.next();
|
||||
for haystack_ch in completion.label.text.chars() {
|
||||
if let Some(needle_ch) = current_needle {
|
||||
if haystack_ch.eq_ignore_ascii_case(&needle_ch) {
|
||||
if let Some(needle_ch) = current_needle
|
||||
&& haystack_ch.eq_ignore_ascii_case(&needle_ch) {
|
||||
current_needle = text_to_replace.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
current_needle.is_none()
|
||||
}
|
||||
|
@ -21604,12 +21552,11 @@ impl<'a> Iterator for WordBreakingTokenizer<'a> {
|
|||
offset += first_grapheme.len();
|
||||
grapheme_len += 1;
|
||||
if is_grapheme_ideographic(first_grapheme) && !is_whitespace {
|
||||
if let Some(grapheme) = iter.peek().copied() {
|
||||
if should_stay_with_preceding_ideograph(grapheme) {
|
||||
if let Some(grapheme) = iter.peek().copied()
|
||||
&& should_stay_with_preceding_ideograph(grapheme) {
|
||||
offset += grapheme.len();
|
||||
grapheme_len += 1;
|
||||
}
|
||||
}
|
||||
} else {
|
||||
let mut words = self.input[offset..].split_word_bound_indices().peekable();
|
||||
let mut next_word_bound = words.peek().copied();
|
||||
|
|
|
@ -916,8 +916,7 @@ impl EditorElement {
|
|||
cx.stop_propagation();
|
||||
} else if cfg!(any(target_os = "linux", target_os = "freebsd"))
|
||||
&& event.button == MouseButton::Middle
|
||||
{
|
||||
if !text_hitbox.is_hovered(window) || editor.read_only(cx) {
|
||||
&& (!text_hitbox.is_hovered(window) || editor.read_only(cx)) {
|
||||
return;
|
||||
}
|
||||
|
||||
|
@ -940,7 +939,6 @@ impl EditorElement {
|
|||
}
|
||||
cx.stop_propagation()
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn click(
|
||||
|
@ -1387,8 +1385,7 @@ impl EditorElement {
|
|||
ref drop_cursor,
|
||||
ref hide_drop_cursor,
|
||||
} = editor.selection_drag_state
|
||||
{
|
||||
if !hide_drop_cursor
|
||||
&& !hide_drop_cursor
|
||||
&& (drop_cursor
|
||||
.start
|
||||
.cmp(&selection.start, &snapshot.buffer_snapshot)
|
||||
|
@ -1410,7 +1407,6 @@ impl EditorElement {
|
|||
let absent_color = cx.theme().players().absent();
|
||||
selections.push((absent_color, vec![drag_cursor_layout]));
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(collaboration_hub) = &editor.collaboration_hub {
|
||||
|
@ -1420,20 +1416,16 @@ impl EditorElement {
|
|||
CollaboratorId::PeerId(peer_id) => {
|
||||
if let Some(collaborator) =
|
||||
collaboration_hub.collaborators(cx).get(&peer_id)
|
||||
{
|
||||
if let Some(participant_index) = collaboration_hub
|
||||
&& let Some(participant_index) = collaboration_hub
|
||||
.user_participant_indices(cx)
|
||||
.get(&collaborator.user_id)
|
||||
{
|
||||
if let Some((local_selection_style, _)) = selections.first_mut()
|
||||
&& let Some((local_selection_style, _)) = selections.first_mut()
|
||||
{
|
||||
*local_selection_style = cx
|
||||
.theme()
|
||||
.players()
|
||||
.color_for_participant(participant_index.0);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
CollaboratorId::Agent => {
|
||||
if let Some((local_selection_style, _)) = selections.first_mut() {
|
||||
|
@ -3518,10 +3510,10 @@ impl EditorElement {
|
|||
let mut x_offset = px(0.);
|
||||
let mut is_block = true;
|
||||
|
||||
if let BlockId::Custom(custom_block_id) = block_id {
|
||||
if block.has_height() {
|
||||
if block.place_near() {
|
||||
if let Some((x_target, line_width)) = x_position {
|
||||
if let BlockId::Custom(custom_block_id) = block_id
|
||||
&& block.has_height() {
|
||||
if block.place_near()
|
||||
&& let Some((x_target, line_width)) = x_position {
|
||||
let margin = em_width * 2;
|
||||
if line_width + final_size.width + margin
|
||||
< editor_width + editor_margins.gutter.full_width()
|
||||
|
@ -3540,13 +3532,11 @@ impl EditorElement {
|
|||
.max(editor_margins.gutter.full_width());
|
||||
x_offset = x_target.min(max_offset).max(min_offset);
|
||||
}
|
||||
}
|
||||
};
|
||||
};
|
||||
if element_height_in_lines != block.height() {
|
||||
resized_blocks.insert(custom_block_id, element_height_in_lines);
|
||||
}
|
||||
}
|
||||
}
|
||||
for i in 0..element_height_in_lines {
|
||||
row_block_types.insert(row + i, is_block);
|
||||
}
|
||||
|
@ -3987,10 +3977,10 @@ impl EditorElement {
|
|||
}
|
||||
}
|
||||
|
||||
if let Some(focused_block) = focused_block {
|
||||
if let Some(focus_handle) = focused_block.focus_handle.upgrade() {
|
||||
if focus_handle.is_focused(window) {
|
||||
if let Some(block) = snapshot.block_for_id(focused_block.id) {
|
||||
if let Some(focused_block) = focused_block
|
||||
&& let Some(focus_handle) = focused_block.focus_handle.upgrade()
|
||||
&& focus_handle.is_focused(window)
|
||||
&& let Some(block) = snapshot.block_for_id(focused_block.id) {
|
||||
let style = block.style();
|
||||
let width = match style {
|
||||
BlockStyle::Fixed => AvailableSpace::MinContent,
|
||||
|
@ -4040,9 +4030,6 @@ impl EditorElement {
|
|||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if resized_blocks.is_empty() {
|
||||
*scroll_width =
|
||||
|
@ -4203,8 +4190,8 @@ impl EditorElement {
|
|||
edit_prediction_popover_visible = true;
|
||||
}
|
||||
|
||||
if editor.context_menu_visible() {
|
||||
if let Some(crate::ContextMenuOrigin::Cursor) = editor.context_menu_origin() {
|
||||
if editor.context_menu_visible()
|
||||
&& let Some(crate::ContextMenuOrigin::Cursor) = editor.context_menu_origin() {
|
||||
let (min_height_in_lines, max_height_in_lines) = editor
|
||||
.context_menu_options
|
||||
.as_ref()
|
||||
|
@ -4216,7 +4203,6 @@ impl EditorElement {
|
|||
max_menu_height += line_height * max_height_in_lines as f32 + POPOVER_Y_PADDING;
|
||||
context_menu_visible = true;
|
||||
}
|
||||
}
|
||||
context_menu_placement = editor
|
||||
.context_menu_options
|
||||
.as_ref()
|
||||
|
@ -5761,8 +5747,8 @@ impl EditorElement {
|
|||
cx: &mut App,
|
||||
) {
|
||||
for (_, hunk_hitbox) in &layout.display_hunks {
|
||||
if let Some(hunk_hitbox) = hunk_hitbox {
|
||||
if !self
|
||||
if let Some(hunk_hitbox) = hunk_hitbox
|
||||
&& !self
|
||||
.editor
|
||||
.read(cx)
|
||||
.buffer()
|
||||
|
@ -5771,7 +5757,6 @@ impl EditorElement {
|
|||
{
|
||||
window.set_cursor_style(CursorStyle::PointingHand, hunk_hitbox);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
let show_git_gutter = layout
|
||||
|
@ -10152,11 +10137,10 @@ fn compute_auto_height_layout(
|
|||
let overscroll = size(em_width, px(0.));
|
||||
|
||||
let editor_width = text_width - gutter_dimensions.margin - overscroll.width - em_width;
|
||||
if !matches!(editor.soft_wrap_mode(cx), SoftWrap::None) {
|
||||
if editor.set_wrap_width(Some(editor_width), cx) {
|
||||
if !matches!(editor.soft_wrap_mode(cx), SoftWrap::None)
|
||||
&& editor.set_wrap_width(Some(editor_width), cx) {
|
||||
snapshot = editor.snapshot(window, cx);
|
||||
}
|
||||
}
|
||||
|
||||
let scroll_height = (snapshot.max_point().row().next_row().0 as f32) * line_height;
|
||||
|
||||
|
|
|
@ -312,11 +312,10 @@ impl GitBlame {
|
|||
.as_ref()
|
||||
.and_then(|entry| entry.author.as_ref())
|
||||
.map(|author| author.len());
|
||||
if let Some(author_len) = author_len {
|
||||
if author_len > max_author_length {
|
||||
if let Some(author_len) = author_len
|
||||
&& author_len > max_author_length {
|
||||
max_author_length = author_len;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
max_author_length
|
||||
|
@ -416,8 +415,7 @@ impl GitBlame {
|
|||
if row_edits
|
||||
.peek()
|
||||
.map_or(true, |next_edit| next_edit.old.start >= old_end)
|
||||
{
|
||||
if let Some(entry) = cursor.item() {
|
||||
&& let Some(entry) = cursor.item() {
|
||||
if old_end > edit.old.end {
|
||||
new_entries.push(
|
||||
GitBlameEntry {
|
||||
|
@ -430,7 +428,6 @@ impl GitBlame {
|
|||
|
||||
cursor.next();
|
||||
}
|
||||
}
|
||||
}
|
||||
new_entries.append(cursor.suffix(), &());
|
||||
drop(cursor);
|
||||
|
|
|
@ -418,8 +418,7 @@ pub fn update_inlay_link_and_hover_points(
|
|||
}
|
||||
if let Some((language_server_id, location)) =
|
||||
hovered_hint_part.location
|
||||
{
|
||||
if secondary_held
|
||||
&& secondary_held
|
||||
&& !editor.has_pending_nonempty_selection()
|
||||
{
|
||||
go_to_definition_updated = true;
|
||||
|
@ -436,7 +435,6 @@ pub fn update_inlay_link_and_hover_points(
|
|||
cx,
|
||||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
};
|
||||
|
@ -766,11 +764,10 @@ pub(crate) fn find_url_from_range(
|
|||
let mut finder = LinkFinder::new();
|
||||
finder.kinds(&[LinkKind::Url]);
|
||||
|
||||
if let Some(link) = finder.links(&text).next() {
|
||||
if link.start() == 0 && link.end() == text.len() {
|
||||
if let Some(link) = finder.links(&text).next()
|
||||
&& link.start() == 0 && link.end() == text.len() {
|
||||
return Some(link.as_str().to_string());
|
||||
}
|
||||
}
|
||||
|
||||
None
|
||||
}
|
||||
|
|
|
@ -142,12 +142,11 @@ pub fn hover_at_inlay(
|
|||
.info_popovers
|
||||
.iter()
|
||||
.any(|InfoPopover { symbol_range, .. }| {
|
||||
if let RangeInEditor::Inlay(range) = symbol_range {
|
||||
if range == &inlay_hover.range {
|
||||
if let RangeInEditor::Inlay(range) = symbol_range
|
||||
&& range == &inlay_hover.range {
|
||||
// Hover triggered from same location as last time. Don't show again.
|
||||
return true;
|
||||
}
|
||||
}
|
||||
false
|
||||
})
|
||||
{
|
||||
|
@ -270,14 +269,13 @@ fn show_hover(
|
|||
}
|
||||
|
||||
// Don't request again if the location is the same as the previous request
|
||||
if let Some(triggered_from) = &editor.hover_state.triggered_from {
|
||||
if triggered_from
|
||||
if let Some(triggered_from) = &editor.hover_state.triggered_from
|
||||
&& triggered_from
|
||||
.cmp(&anchor, &snapshot.buffer_snapshot)
|
||||
.is_eq()
|
||||
{
|
||||
return None;
|
||||
}
|
||||
}
|
||||
|
||||
let hover_popover_delay = EditorSettings::get_global(cx).hover_popover_delay;
|
||||
let all_diagnostics_active = editor.active_diagnostics == ActiveDiagnostic::All;
|
||||
|
@ -717,9 +715,9 @@ pub fn diagnostics_markdown_style(window: &Window, cx: &App) -> MarkdownStyle {
|
|||
}
|
||||
|
||||
pub fn open_markdown_url(link: SharedString, window: &mut Window, cx: &mut App) {
|
||||
if let Ok(uri) = Url::parse(&link) {
|
||||
if uri.scheme() == "file" {
|
||||
if let Some(workspace) = window.root::<Workspace>().flatten() {
|
||||
if let Ok(uri) = Url::parse(&link)
|
||||
&& uri.scheme() == "file"
|
||||
&& let Some(workspace) = window.root::<Workspace>().flatten() {
|
||||
workspace.update(cx, |workspace, cx| {
|
||||
let task = workspace.open_abs_path(
|
||||
PathBuf::from(uri.path()),
|
||||
|
@ -769,8 +767,6 @@ pub fn open_markdown_url(link: SharedString, window: &mut Window, cx: &mut App)
|
|||
});
|
||||
return;
|
||||
}
|
||||
}
|
||||
}
|
||||
cx.open_url(&link);
|
||||
}
|
||||
|
||||
|
@ -839,21 +835,19 @@ impl HoverState {
|
|||
pub fn focused(&self, window: &mut Window, cx: &mut Context<Editor>) -> bool {
|
||||
let mut hover_popover_is_focused = false;
|
||||
for info_popover in &self.info_popovers {
|
||||
if let Some(markdown_view) = &info_popover.parsed_content {
|
||||
if markdown_view.focus_handle(cx).is_focused(window) {
|
||||
if let Some(markdown_view) = &info_popover.parsed_content
|
||||
&& markdown_view.focus_handle(cx).is_focused(window) {
|
||||
hover_popover_is_focused = true;
|
||||
}
|
||||
}
|
||||
}
|
||||
if let Some(diagnostic_popover) = &self.diagnostic_popover {
|
||||
if diagnostic_popover
|
||||
if let Some(diagnostic_popover) = &self.diagnostic_popover
|
||||
&& diagnostic_popover
|
||||
.markdown
|
||||
.focus_handle(cx)
|
||||
.is_focused(window)
|
||||
{
|
||||
hover_popover_is_focused = true;
|
||||
}
|
||||
}
|
||||
hover_popover_is_focused
|
||||
}
|
||||
}
|
||||
|
|
|
@ -168,12 +168,11 @@ pub fn indent_guides_in_range(
|
|||
while let Some(fold) = folds.next() {
|
||||
let start = fold.range.start.to_point(&snapshot.buffer_snapshot);
|
||||
let end = fold.range.end.to_point(&snapshot.buffer_snapshot);
|
||||
if let Some(last_range) = fold_ranges.last_mut() {
|
||||
if last_range.end >= start {
|
||||
if let Some(last_range) = fold_ranges.last_mut()
|
||||
&& last_range.end >= start {
|
||||
last_range.end = last_range.end.max(end);
|
||||
continue;
|
||||
}
|
||||
}
|
||||
fold_ranges.push(start..end);
|
||||
}
|
||||
|
||||
|
|
|
@ -498,8 +498,7 @@ impl InlayHintCache {
|
|||
cmp::Ordering::Less | cmp::Ordering::Equal => {
|
||||
if !old_kinds.contains(&cached_hint.kind)
|
||||
&& new_kinds.contains(&cached_hint.kind)
|
||||
{
|
||||
if let Some(anchor) = multi_buffer_snapshot
|
||||
&& let Some(anchor) = multi_buffer_snapshot
|
||||
.anchor_in_excerpt(*excerpt_id, cached_hint.position)
|
||||
{
|
||||
to_insert.push(Inlay::hint(
|
||||
|
@ -508,7 +507,6 @@ impl InlayHintCache {
|
|||
cached_hint,
|
||||
));
|
||||
}
|
||||
}
|
||||
excerpt_cache.next();
|
||||
}
|
||||
cmp::Ordering::Greater => return true,
|
||||
|
@ -522,8 +520,8 @@ impl InlayHintCache {
|
|||
for cached_hint_id in excerpt_cache {
|
||||
let maybe_missed_cached_hint = &excerpt_cached_hints.hints_by_id[cached_hint_id];
|
||||
let cached_hint_kind = maybe_missed_cached_hint.kind;
|
||||
if !old_kinds.contains(&cached_hint_kind) && new_kinds.contains(&cached_hint_kind) {
|
||||
if let Some(anchor) = multi_buffer_snapshot
|
||||
if !old_kinds.contains(&cached_hint_kind) && new_kinds.contains(&cached_hint_kind)
|
||||
&& let Some(anchor) = multi_buffer_snapshot
|
||||
.anchor_in_excerpt(*excerpt_id, maybe_missed_cached_hint.position)
|
||||
{
|
||||
to_insert.push(Inlay::hint(
|
||||
|
@ -532,7 +530,6 @@ impl InlayHintCache {
|
|||
maybe_missed_cached_hint,
|
||||
));
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
|
@ -620,8 +617,8 @@ impl InlayHintCache {
|
|||
) {
|
||||
if let Some(excerpt_hints) = self.hints.get(&excerpt_id) {
|
||||
let mut guard = excerpt_hints.write();
|
||||
if let Some(cached_hint) = guard.hints_by_id.get_mut(&id) {
|
||||
if let ResolveState::CanResolve(server_id, _) = &cached_hint.resolve_state {
|
||||
if let Some(cached_hint) = guard.hints_by_id.get_mut(&id)
|
||||
&& let ResolveState::CanResolve(server_id, _) = &cached_hint.resolve_state {
|
||||
let hint_to_resolve = cached_hint.clone();
|
||||
let server_id = *server_id;
|
||||
cached_hint.resolve_state = ResolveState::Resolving;
|
||||
|
@ -644,12 +641,11 @@ impl InlayHintCache {
|
|||
editor.inlay_hint_cache.hints.get(&excerpt_id)
|
||||
{
|
||||
let mut guard = excerpt_hints.write();
|
||||
if let Some(cached_hint) = guard.hints_by_id.get_mut(&id) {
|
||||
if cached_hint.resolve_state == ResolveState::Resolving {
|
||||
if let Some(cached_hint) = guard.hints_by_id.get_mut(&id)
|
||||
&& cached_hint.resolve_state == ResolveState::Resolving {
|
||||
resolved_hint.resolve_state = ResolveState::Resolved;
|
||||
*cached_hint = resolved_hint;
|
||||
}
|
||||
}
|
||||
}
|
||||
})?;
|
||||
}
|
||||
|
@ -658,7 +654,6 @@ impl InlayHintCache {
|
|||
})
|
||||
.detach_and_log_err(cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -990,8 +985,8 @@ fn fetch_and_update_hints(
|
|||
|
||||
let buffer = editor.buffer().read(cx).buffer(query.buffer_id)?;
|
||||
|
||||
if !editor.registered_buffers.contains_key(&query.buffer_id) {
|
||||
if let Some(project) = editor.project.as_ref() {
|
||||
if !editor.registered_buffers.contains_key(&query.buffer_id)
|
||||
&& let Some(project) = editor.project.as_ref() {
|
||||
project.update(cx, |project, cx| {
|
||||
editor.registered_buffers.insert(
|
||||
query.buffer_id,
|
||||
|
@ -999,7 +994,6 @@ fn fetch_and_update_hints(
|
|||
);
|
||||
})
|
||||
}
|
||||
}
|
||||
|
||||
editor
|
||||
.semantics_provider
|
||||
|
@ -1240,15 +1234,13 @@ fn apply_hint_update(
|
|||
.inlay_hint_cache
|
||||
.allowed_hint_kinds
|
||||
.contains(&new_hint.kind)
|
||||
{
|
||||
if let Some(new_hint_position) =
|
||||
&& let Some(new_hint_position) =
|
||||
multi_buffer_snapshot.anchor_in_excerpt(query.excerpt_id, new_hint.position)
|
||||
{
|
||||
splice
|
||||
.to_insert
|
||||
.push(Inlay::hint(new_inlay_id, new_hint_position, &new_hint));
|
||||
}
|
||||
}
|
||||
let new_id = InlayId::Hint(new_inlay_id);
|
||||
cached_excerpt_hints.hints_by_id.insert(new_id, new_hint);
|
||||
if cached_excerpt_hints.ordered_hints.len() <= insert_position {
|
||||
|
|
|
@ -930,11 +930,10 @@ impl Item for Editor {
|
|||
})?;
|
||||
buffer
|
||||
.update(cx, |buffer, cx| {
|
||||
if let Some(transaction) = transaction {
|
||||
if !buffer.is_singleton() {
|
||||
if let Some(transaction) = transaction
|
||||
&& !buffer.is_singleton() {
|
||||
buffer.push_transaction(&transaction.0, cx);
|
||||
}
|
||||
}
|
||||
})
|
||||
.ok();
|
||||
Ok(())
|
||||
|
@ -1374,9 +1373,8 @@ impl ProjectItem for Editor {
|
|||
let mut editor = Self::for_buffer(buffer.clone(), Some(project), window, cx);
|
||||
if let Some((excerpt_id, buffer_id, snapshot)) =
|
||||
editor.buffer().read(cx).snapshot(cx).as_singleton()
|
||||
{
|
||||
if WorkspaceSettings::get(None, cx).restore_on_file_reopen {
|
||||
if let Some(restoration_data) = Self::project_item_kind()
|
||||
&& WorkspaceSettings::get(None, cx).restore_on_file_reopen
|
||||
&& let Some(restoration_data) = Self::project_item_kind()
|
||||
.and_then(|kind| pane.as_ref()?.project_item_restoration_data.get(&kind))
|
||||
.and_then(|data| data.downcast_ref::<EditorRestorationData>())
|
||||
.and_then(|data| {
|
||||
|
@ -1403,8 +1401,6 @@ impl ProjectItem for Editor {
|
|||
);
|
||||
editor.set_scroll_anchor(ScrollAnchor { anchor, offset }, window, cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
editor
|
||||
}
|
||||
|
|
|
@ -51,13 +51,11 @@ pub(crate) fn should_auto_close(
|
|||
continue;
|
||||
};
|
||||
let mut jsx_open_tag_node = node;
|
||||
if node.grammar_name() != config.open_tag_node_name {
|
||||
if let Some(parent) = node.parent() {
|
||||
if parent.grammar_name() == config.open_tag_node_name {
|
||||
if node.grammar_name() != config.open_tag_node_name
|
||||
&& let Some(parent) = node.parent()
|
||||
&& parent.grammar_name() == config.open_tag_node_name {
|
||||
jsx_open_tag_node = parent;
|
||||
}
|
||||
}
|
||||
}
|
||||
if jsx_open_tag_node.grammar_name() != config.open_tag_node_name {
|
||||
continue;
|
||||
}
|
||||
|
@ -284,11 +282,10 @@ pub(crate) fn generate_auto_close_edits(
|
|||
unclosed_open_tag_count -= 1;
|
||||
}
|
||||
} else if has_erroneous_close_tag && kind == erroneous_close_tag_node_name {
|
||||
if tag_node_name_equals(&node, &tag_name) {
|
||||
if !is_after_open_tag(&node) {
|
||||
if tag_node_name_equals(&node, &tag_name)
|
||||
&& !is_after_open_tag(&node) {
|
||||
unclosed_open_tag_count -= 1;
|
||||
}
|
||||
}
|
||||
} else if kind == config.jsx_element_node_name {
|
||||
// perf: filter only open,close,element,erroneous nodes
|
||||
stack.extend(node.children(&mut cursor));
|
||||
|
|
|
@ -147,8 +147,8 @@ pub fn lsp_tasks(
|
|||
},
|
||||
cx,
|
||||
)
|
||||
}) {
|
||||
if let Some(new_runnables) = runnables_task.await.log_err() {
|
||||
})
|
||||
&& let Some(new_runnables) = runnables_task.await.log_err() {
|
||||
new_lsp_tasks.extend(new_runnables.runnables.into_iter().filter_map(
|
||||
|(location, runnable)| {
|
||||
let resolved_task =
|
||||
|
@ -157,7 +157,6 @@ pub fn lsp_tasks(
|
|||
},
|
||||
));
|
||||
}
|
||||
}
|
||||
lsp_tasks
|
||||
.entry(source_kind)
|
||||
.or_insert_with(Vec::new)
|
||||
|
|
|
@ -510,11 +510,10 @@ pub fn find_preceding_boundary_point(
|
|||
if find_range == FindRange::SingleLine && ch == '\n' {
|
||||
break;
|
||||
}
|
||||
if let Some(prev_ch) = prev_ch {
|
||||
if is_boundary(ch, prev_ch) {
|
||||
if let Some(prev_ch) = prev_ch
|
||||
&& is_boundary(ch, prev_ch) {
|
||||
break;
|
||||
}
|
||||
}
|
||||
|
||||
offset -= ch.len_utf8();
|
||||
prev_ch = Some(ch);
|
||||
|
@ -562,15 +561,14 @@ pub fn find_boundary_point(
|
|||
if find_range == FindRange::SingleLine && ch == '\n' {
|
||||
break;
|
||||
}
|
||||
if let Some(prev_ch) = prev_ch {
|
||||
if is_boundary(prev_ch, ch) {
|
||||
if let Some(prev_ch) = prev_ch
|
||||
&& is_boundary(prev_ch, ch) {
|
||||
if return_point_before_boundary {
|
||||
return map.clip_point(prev_offset.to_display_point(map), Bias::Right);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
prev_offset = offset;
|
||||
offset += ch.len_utf8();
|
||||
prev_ch = Some(ch);
|
||||
|
@ -603,15 +601,14 @@ pub fn find_preceding_boundary_trail(
|
|||
// Find the boundary
|
||||
let start_offset = offset;
|
||||
for ch in forward {
|
||||
if let Some(prev_ch) = prev_ch {
|
||||
if is_boundary(prev_ch, ch) {
|
||||
if let Some(prev_ch) = prev_ch
|
||||
&& is_boundary(prev_ch, ch) {
|
||||
if start_offset == offset {
|
||||
trail_offset = Some(offset);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
offset -= ch.len_utf8();
|
||||
prev_ch = Some(ch);
|
||||
}
|
||||
|
@ -651,15 +648,14 @@ pub fn find_boundary_trail(
|
|||
// Find the boundary
|
||||
let start_offset = offset;
|
||||
for ch in forward {
|
||||
if let Some(prev_ch) = prev_ch {
|
||||
if is_boundary(prev_ch, ch) {
|
||||
if let Some(prev_ch) = prev_ch
|
||||
&& is_boundary(prev_ch, ch) {
|
||||
if start_offset == offset {
|
||||
trail_offset = Some(offset);
|
||||
} else {
|
||||
break;
|
||||
}
|
||||
}
|
||||
}
|
||||
offset += ch.len_utf8();
|
||||
prev_ch = Some(ch);
|
||||
}
|
||||
|
|
|
@ -285,12 +285,11 @@ pub fn open_docs(editor: &mut Editor, _: &OpenDocs, window: &mut Window, cx: &mu
|
|||
workspace.update(cx, |_workspace, cx| {
|
||||
// Check if the local document exists, otherwise fallback to the online document.
|
||||
// Open with the default browser.
|
||||
if let Some(local_url) = docs_urls.local {
|
||||
if fs::metadata(Path::new(&local_url[8..])).is_ok() {
|
||||
if let Some(local_url) = docs_urls.local
|
||||
&& fs::metadata(Path::new(&local_url[8..])).is_ok() {
|
||||
cx.open_url(&local_url);
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
if let Some(web_url) = docs_urls.web {
|
||||
cx.open_url(&web_url);
|
||||
|
|
|
@ -703,21 +703,19 @@ impl Editor {
|
|||
if matches!(
|
||||
settings.defaults.soft_wrap,
|
||||
SoftWrap::PreferredLineLength | SoftWrap::Bounded
|
||||
) {
|
||||
if (settings.defaults.preferred_line_length as f32) < visible_column_count {
|
||||
)
|
||||
&& (settings.defaults.preferred_line_length as f32) < visible_column_count {
|
||||
visible_column_count = settings.defaults.preferred_line_length as f32;
|
||||
}
|
||||
}
|
||||
|
||||
// If the scroll position is currently at the left edge of the document
|
||||
// (x == 0.0) and the intent is to scroll right, the gutter's margin
|
||||
// should first be added to the current position, otherwise the cursor
|
||||
// will end at the column position minus the margin, which looks off.
|
||||
if current_position.x == 0.0 && amount.columns(visible_column_count) > 0. {
|
||||
if let Some(last_position_map) = &self.last_position_map {
|
||||
if current_position.x == 0.0 && amount.columns(visible_column_count) > 0.
|
||||
&& let Some(last_position_map) = &self.last_position_map {
|
||||
current_position.x += self.gutter_dimensions.margin / last_position_map.em_advance;
|
||||
}
|
||||
}
|
||||
let new_position = current_position
|
||||
+ point(
|
||||
amount.columns(visible_column_count),
|
||||
|
@ -749,13 +747,11 @@ impl Editor {
|
|||
|
||||
if let (Some(visible_lines), Some(visible_columns)) =
|
||||
(self.visible_line_count(), self.visible_column_count())
|
||||
{
|
||||
if newest_head.row() <= DisplayRow(screen_top.row().0 + visible_lines as u32)
|
||||
&& newest_head.row() <= DisplayRow(screen_top.row().0 + visible_lines as u32)
|
||||
&& newest_head.column() <= screen_top.column() + visible_columns as u32
|
||||
{
|
||||
return Ordering::Equal;
|
||||
}
|
||||
}
|
||||
|
||||
Ordering::Greater
|
||||
}
|
||||
|
|
|
@ -116,14 +116,13 @@ impl Editor {
|
|||
let display_map = self.display_map.update(cx, |map, cx| map.snapshot(cx));
|
||||
let mut scroll_position = self.scroll_manager.scroll_position(&display_map);
|
||||
let original_y = scroll_position.y;
|
||||
if let Some(last_bounds) = self.expect_bounds_change.take() {
|
||||
if scroll_position.y != 0. {
|
||||
if let Some(last_bounds) = self.expect_bounds_change.take()
|
||||
&& scroll_position.y != 0. {
|
||||
scroll_position.y += (bounds.top() - last_bounds.top()) / line_height;
|
||||
if scroll_position.y < 0. {
|
||||
scroll_position.y = 0.;
|
||||
}
|
||||
}
|
||||
}
|
||||
if scroll_position.y > max_scroll_top {
|
||||
scroll_position.y = max_scroll_top;
|
||||
}
|
||||
|
|
|
@ -184,11 +184,10 @@ pub fn editor_content_with_blocks(editor: &Entity<Editor>, cx: &mut VisualTestCo
|
|||
for (row, block) in blocks {
|
||||
match block {
|
||||
Block::Custom(custom_block) => {
|
||||
if let BlockPlacement::Near(x) = &custom_block.placement {
|
||||
if snapshot.intersects_fold(x.to_point(&snapshot.buffer_snapshot)) {
|
||||
if let BlockPlacement::Near(x) = &custom_block.placement
|
||||
&& snapshot.intersects_fold(x.to_point(&snapshot.buffer_snapshot)) {
|
||||
continue;
|
||||
}
|
||||
};
|
||||
};
|
||||
let content = block_content_for_tests(editor, custom_block.id, cx)
|
||||
.expect("block content not found");
|
||||
// 2: "related info 1 for diagnostic 0"
|
||||
|
|
|
@ -167,15 +167,14 @@ fn main() {
|
|||
continue;
|
||||
}
|
||||
|
||||
if let Some(language) = meta.language_server {
|
||||
if !languages.contains(&language.file_extension) {
|
||||
if let Some(language) = meta.language_server
|
||||
&& !languages.contains(&language.file_extension) {
|
||||
panic!(
|
||||
"Eval for {:?} could not be run because no language server was found for extension {:?}",
|
||||
meta.name,
|
||||
language.file_extension
|
||||
);
|
||||
}
|
||||
}
|
||||
|
||||
// TODO: This creates a worktree per repetition. Ideally these examples should
|
||||
// either be run sequentially on the same worktree, or reuse worktrees when there
|
||||
|
|
|
@ -46,28 +46,24 @@ fn find_target_files_recursive(
|
|||
max_depth,
|
||||
found_files,
|
||||
)?;
|
||||
} else if path.is_file() {
|
||||
if let Some(filename_osstr) = path.file_name() {
|
||||
if let Some(filename_str) = filename_osstr.to_str() {
|
||||
if filename_str == target_filename {
|
||||
} else if path.is_file()
|
||||
&& let Some(filename_osstr) = path.file_name()
|
||||
&& let Some(filename_str) = filename_osstr.to_str()
|
||||
&& filename_str == target_filename {
|
||||
found_files.push(path);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
Ok(())
|
||||
}
|
||||
|
||||
pub fn generate_explorer_html(input_paths: &[PathBuf], output_path: &PathBuf) -> Result<String> {
|
||||
if let Some(parent) = output_path.parent() {
|
||||
if !parent.exists() {
|
||||
if let Some(parent) = output_path.parent()
|
||||
&& !parent.exists() {
|
||||
fs::create_dir_all(parent).context(format!(
|
||||
"Failed to create output directory: {}",
|
||||
parent.display()
|
||||
))?;
|
||||
}
|
||||
}
|
||||
|
||||
let template_path = PathBuf::from(env!("CARGO_MANIFEST_DIR")).join("src/explorer.html");
|
||||
let template_content = fs::read_to_string(&template_path).context(format!(
|
||||
|
|
|
@ -376,11 +376,10 @@ impl ExampleInstance {
|
|||
);
|
||||
let result = this.thread.conversation(&mut example_cx).await;
|
||||
|
||||
if let Err(err) = result {
|
||||
if !err.is::<FailedAssertion>() {
|
||||
if let Err(err) = result
|
||||
&& !err.is::<FailedAssertion>() {
|
||||
return Err(err);
|
||||
}
|
||||
}
|
||||
|
||||
println!("{}Stopped", this.log_prefix);
|
||||
|
||||
|
|
|
@ -178,8 +178,7 @@ pub fn parse_wasm_extension_version(
|
|||
for part in wasmparser::Parser::new(0).parse_all(wasm_bytes) {
|
||||
if let wasmparser::Payload::CustomSection(s) =
|
||||
part.context("error parsing wasm extension")?
|
||||
{
|
||||
if s.name() == "zed:api-version" {
|
||||
&& s.name() == "zed:api-version" {
|
||||
version = parse_wasm_extension_version_custom_section(s.data());
|
||||
if version.is_none() {
|
||||
bail!(
|
||||
|
@ -189,7 +188,6 @@ pub fn parse_wasm_extension_version(
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The reason we wait until we're done parsing all of the Wasm bytes to return the version
|
||||
|
|
|
@ -93,11 +93,9 @@ pub fn is_version_compatible(
|
|||
.wasm_api_version
|
||||
.as_ref()
|
||||
.and_then(|wasm_api_version| SemanticVersion::from_str(wasm_api_version).ok())
|
||||
{
|
||||
if !is_supported_wasm_api_version(release_channel, wasm_api_version) {
|
||||
&& !is_supported_wasm_api_version(release_channel, wasm_api_version) {
|
||||
return false;
|
||||
}
|
||||
}
|
||||
|
||||
true
|
||||
}
|
||||
|
@ -292,21 +290,18 @@ impl ExtensionStore {
|
|||
// it must be asynchronously rebuilt.
|
||||
let mut extension_index = ExtensionIndex::default();
|
||||
let mut extension_index_needs_rebuild = true;
|
||||
if let Ok(index_content) = index_content {
|
||||
if let Some(index) = serde_json::from_str(&index_content).log_err() {
|
||||
if let Ok(index_content) = index_content
|
||||
&& let Some(index) = serde_json::from_str(&index_content).log_err() {
|
||||
extension_index = index;
|
||||
if let (Ok(Some(index_metadata)), Ok(Some(extensions_metadata))) =
|
||||
(index_metadata, extensions_metadata)
|
||||
{
|
||||
if index_metadata
|
||||
&& index_metadata
|
||||
.mtime
|
||||
.bad_is_greater_than(extensions_metadata.mtime)
|
||||
{
|
||||
extension_index_needs_rebuild = false;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// Immediately load all of the extensions in the initial manifest. If the
|
||||
// index needs to be rebuild, then enqueue
|
||||
|
@ -392,11 +387,9 @@ impl ExtensionStore {
|
|||
|
||||
if let Some(path::Component::Normal(extension_dir_name)) =
|
||||
event_path.components().next()
|
||||
{
|
||||
if let Some(extension_id) = extension_dir_name.to_str() {
|
||||
&& let Some(extension_id) = extension_dir_name.to_str() {
|
||||
reload_tx.unbounded_send(Some(extension_id.into())).ok();
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
@ -763,8 +756,8 @@ impl ExtensionStore {
|
|||
if let ExtensionOperation::Install = operation {
|
||||
this.update( cx, |this, cx| {
|
||||
cx.emit(Event::ExtensionInstalled(extension_id.clone()));
|
||||
if let Some(events) = ExtensionEvents::try_global(cx) {
|
||||
if let Some(manifest) = this.extension_manifest_for_id(&extension_id) {
|
||||
if let Some(events) = ExtensionEvents::try_global(cx)
|
||||
&& let Some(manifest) = this.extension_manifest_for_id(&extension_id) {
|
||||
events.update(cx, |this, cx| {
|
||||
this.emit(
|
||||
extension::Event::ExtensionInstalled(manifest.clone()),
|
||||
|
@ -772,7 +765,6 @@ impl ExtensionStore {
|
|||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
})
|
||||
.ok();
|
||||
}
|
||||
|
@ -912,13 +904,12 @@ impl ExtensionStore {
|
|||
|
||||
extension_store.update(cx, |_, cx| {
|
||||
cx.emit(Event::ExtensionUninstalled(extension_id.clone()));
|
||||
if let Some(events) = ExtensionEvents::try_global(cx) {
|
||||
if let Some(manifest) = extension_manifest {
|
||||
if let Some(events) = ExtensionEvents::try_global(cx)
|
||||
&& let Some(manifest) = extension_manifest {
|
||||
events.update(cx, |this, cx| {
|
||||
this.emit(extension::Event::ExtensionUninstalled(manifest.clone()), cx)
|
||||
});
|
||||
}
|
||||
}
|
||||
})?;
|
||||
|
||||
anyhow::Ok(())
|
||||
|
@ -997,13 +988,12 @@ impl ExtensionStore {
|
|||
this.update(cx, |this, cx| this.reload(None, cx))?.await;
|
||||
this.update(cx, |this, cx| {
|
||||
cx.emit(Event::ExtensionInstalled(extension_id.clone()));
|
||||
if let Some(events) = ExtensionEvents::try_global(cx) {
|
||||
if let Some(manifest) = this.extension_manifest_for_id(&extension_id) {
|
||||
if let Some(events) = ExtensionEvents::try_global(cx)
|
||||
&& let Some(manifest) = this.extension_manifest_for_id(&extension_id) {
|
||||
events.update(cx, |this, cx| {
|
||||
this.emit(extension::Event::ExtensionInstalled(manifest.clone()), cx)
|
||||
});
|
||||
}
|
||||
}
|
||||
})?;
|
||||
|
||||
Ok(())
|
||||
|
@ -1788,11 +1778,10 @@ impl ExtensionStore {
|
|||
let connection_options = client.read(cx).connection_options();
|
||||
let ssh_url = connection_options.ssh_url();
|
||||
|
||||
if let Some(existing_client) = self.ssh_clients.get(&ssh_url) {
|
||||
if existing_client.upgrade().is_some() {
|
||||
if let Some(existing_client) = self.ssh_clients.get(&ssh_url)
|
||||
&& existing_client.upgrade().is_some() {
|
||||
return;
|
||||
}
|
||||
}
|
||||
|
||||
self.ssh_clients.insert(ssh_url, client.downgrade());
|
||||
self.ssh_registered_tx.unbounded_send(()).ok();
|
||||
|
|
|
@ -701,8 +701,7 @@ pub fn parse_wasm_extension_version(
|
|||
for part in wasmparser::Parser::new(0).parse_all(wasm_bytes) {
|
||||
if let wasmparser::Payload::CustomSection(s) =
|
||||
part.context("error parsing wasm extension")?
|
||||
{
|
||||
if s.name() == "zed:api-version" {
|
||||
&& s.name() == "zed:api-version" {
|
||||
version = parse_wasm_extension_version_custom_section(s.data());
|
||||
if version.is_none() {
|
||||
bail!(
|
||||
|
@ -712,7 +711,6 @@ pub fn parse_wasm_extension_version(
|
|||
);
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
// The reason we wait until we're done parsing all of the Wasm bytes to return the version
|
||||
|
|
|
@ -1031,8 +1031,7 @@ impl ExtensionsPage {
|
|||
.read(cx)
|
||||
.extension_manifest_for_id(&extension_id)
|
||||
.cloned()
|
||||
{
|
||||
if let Some(events) = extension::ExtensionEvents::try_global(cx) {
|
||||
&& let Some(events) = extension::ExtensionEvents::try_global(cx) {
|
||||
events.update(cx, |this, cx| {
|
||||
this.emit(
|
||||
extension::Event::ConfigureExtensionRequested(manifest),
|
||||
|
@ -1040,7 +1039,6 @@ impl ExtensionsPage {
|
|||
)
|
||||
});
|
||||
}
|
||||
}
|
||||
}
|
||||
})
|
||||
}),
|
||||
|
|
|
@ -209,12 +209,11 @@ impl FileFinder {
|
|||
let Some(init_modifiers) = self.init_modifiers.take() else {
|
||||
return;
|
||||
};
|
||||
if self.picker.read(cx).delegate.has_changed_selected_index {
|
||||
if !event.modified() || !init_modifiers.is_subset_of(event) {
|
||||
if self.picker.read(cx).delegate.has_changed_selected_index
|
||||
&& (!event.modified() || !init_modifiers.is_subset_of(event)) {
|
||||
self.init_modifiers = None;
|
||||
window.dispatch_action(menu::Confirm.boxed_clone(), cx);
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn handle_select_prev(
|
||||
|
@ -323,8 +322,8 @@ impl FileFinder {
|
|||
) {
|
||||
self.picker.update(cx, |picker, cx| {
|
||||
let delegate = &mut picker.delegate;
|
||||
if let Some(workspace) = delegate.workspace.upgrade() {
|
||||
if let Some(m) = delegate.matches.get(delegate.selected_index()) {
|
||||
if let Some(workspace) = delegate.workspace.upgrade()
|
||||
&& let Some(m) = delegate.matches.get(delegate.selected_index()) {
|
||||
let path = match &m {
|
||||
Match::History { path, .. } => {
|
||||
let worktree_id = path.project.worktree_id;
|
||||
|
@ -344,7 +343,6 @@ impl FileFinder {
|
|||
});
|
||||
open_task.detach_and_log_err(cx);
|
||||
}
|
||||
}
|
||||
})
|
||||
}
|
||||
|
||||
|
@ -675,8 +673,8 @@ impl Matches {
|
|||
let path_str = panel_match.0.path.to_string_lossy();
|
||||
let filename_str = filename.to_string_lossy();
|
||||
|
||||
if let Some(filename_pos) = path_str.rfind(&*filename_str) {
|
||||
if panel_match.0.positions[0] >= filename_pos {
|
||||
if let Some(filename_pos) = path_str.rfind(&*filename_str)
|
||||
&& panel_match.0.positions[0] >= filename_pos {
|
||||
let mut prev_position = panel_match.0.positions[0];
|
||||
for p in &panel_match.0.positions[1..] {
|
||||
if *p != prev_position + 1 {
|
||||
|
@ -686,7 +684,6 @@ impl Matches {
|
|||
}
|
||||
return true;
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
false
|
||||
|
@ -1045,11 +1042,10 @@ impl FileFinderDelegate {
|
|||
)
|
||||
} else {
|
||||
let mut path = Arc::clone(project_relative_path);
|
||||
if project_relative_path.as_ref() == Path::new("") {
|
||||
if let Some(absolute_path) = &entry_path.absolute {
|
||||
if project_relative_path.as_ref() == Path::new("")
|
||||
&& let Some(absolute_path) = &entry_path.absolute {
|
||||
path = Arc::from(absolute_path.as_path());
|
||||
}
|
||||
}
|
||||
|
||||
let mut path_match = PathMatch {
|
||||
score: ix as f64,
|
||||
|
@ -1078,11 +1074,11 @@ impl FileFinderDelegate {
|
|||
),
|
||||
};
|
||||
|
||||
if file_name_positions.is_empty() {
|
||||
if let Some(user_home_path) = std::env::var("HOME").ok() {
|
||||
if file_name_positions.is_empty()
|
||||
&& let Some(user_home_path) = std::env::var("HOME").ok() {
|
||||
let user_home_path = user_home_path.trim();
|
||||
if !user_home_path.is_empty() {
|
||||
if full_path.starts_with(user_home_path) {
|
||||
if !user_home_path.is_empty()
|
||||
&& full_path.starts_with(user_home_path) {
|
||||
full_path.replace_range(0..user_home_path.len(), "~");
|
||||
full_path_positions.retain_mut(|pos| {
|
||||
if *pos >= user_home_path.len() {
|
||||
|
@ -1094,9 +1090,7 @@ impl FileFinderDelegate {
|
|||
}
|
||||
})
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
if full_path.is_ascii() {
|
||||
let file_finder_settings = FileFinderSettings::get_global(cx);
|
||||
|
@ -1242,16 +1236,14 @@ impl FileFinderDelegate {
|
|||
|
||||
/// Skips first history match (that is displayed topmost) if it's currently opened.
|
||||
fn calculate_selected_index(&self, cx: &mut Context<Picker<Self>>) -> usize {
|
||||
if FileFinderSettings::get_global(cx).skip_focus_for_active_in_search {
|
||||
if let Some(Match::History { path, .. }) = self.matches.get(0) {
|
||||
if Some(path) == self.currently_opened_path.as_ref() {
|
||||
if FileFinderSettings::get_global(cx).skip_focus_for_active_in_search
|
||||
&& let Some(Match::History { path, .. }) = self.matches.get(0)
|
||||
&& Some(path) == self.currently_opened_path.as_ref() {
|
||||
let elements_after_first = self.matches.len() - 1;
|
||||
if elements_after_first > 0 {
|
||||
return 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
0
|
||||
}
|
||||
|
@ -1310,11 +1302,10 @@ impl PickerDelegate for FileFinderDelegate {
|
|||
.enumerate()
|
||||
.find(|(_, m)| !matches!(m, Match::History { .. }))
|
||||
.map(|(i, _)| i);
|
||||
if let Some(first_non_history_index) = first_non_history_index {
|
||||
if first_non_history_index > 0 {
|
||||
if let Some(first_non_history_index) = first_non_history_index
|
||||
&& first_non_history_index > 0 {
|
||||
return vec![first_non_history_index - 1];
|
||||
}
|
||||
}
|
||||
}
|
||||
Vec::new()
|
||||
}
|
||||
|
@ -1436,8 +1427,8 @@ impl PickerDelegate for FileFinderDelegate {
|
|||
window: &mut Window,
|
||||
cx: &mut Context<Picker<FileFinderDelegate>>,
|
||||
) {
|
||||
if let Some(m) = self.matches.get(self.selected_index()) {
|
||||
if let Some(workspace) = self.workspace.upgrade() {
|
||||
if let Some(m) = self.matches.get(self.selected_index())
|
||||
&& let Some(workspace) = self.workspace.upgrade() {
|
||||
let open_task = workspace.update(cx, |workspace, cx| {
|
||||
let split_or_open =
|
||||
|workspace: &mut Workspace,
|
||||
|
@ -1568,8 +1559,8 @@ impl PickerDelegate for FileFinderDelegate {
|
|||
|
||||
cx.spawn_in(window, async move |_, cx| {
|
||||
let item = open_task.await.notify_async_err(cx)?;
|
||||
if let Some(row) = row {
|
||||
if let Some(active_editor) = item.downcast::<Editor>() {
|
||||
if let Some(row) = row
|
||||
&& let Some(active_editor) = item.downcast::<Editor>() {
|
||||
active_editor
|
||||
.downgrade()
|
||||
.update_in(cx, |editor, window, cx| {
|
||||
|
@ -1581,14 +1572,12 @@ impl PickerDelegate for FileFinderDelegate {
|
|||
})
|
||||
.log_err();
|
||||
}
|
||||
}
|
||||
finder.update(cx, |_, cx| cx.emit(DismissEvent)).ok()?;
|
||||
|
||||
Some(())
|
||||
})
|
||||
.detach();
|
||||
}
|
||||
}
|
||||
}
|
||||
|
||||
fn dismissed(&mut self, _: &mut Window, cx: &mut Context<Picker<FileFinderDelegate>>) {
|
||||
|
|
|
@ -75,8 +75,8 @@ impl OpenPathDelegate {
|
|||
..
|
||||
} => {
|
||||
let mut i = selected_match_index;
|
||||
if let Some(user_input) = user_input {
|
||||
if !user_input.exists || !user_input.is_dir {
|
||||
if let Some(user_input) = user_input
|
||||
&& (!user_input.exists || !user_input.is_dir) {
|
||||
if i == 0 {
|
||||
return Some(CandidateInfo {
|
||||
path: user_input.file.clone(),
|
||||
|
@ -86,7 +86,6 @@ impl OpenPathDelegate {
|
|||
i -= 1;
|
||||
}
|
||||
}
|
||||
}
|
||||
let id = self.string_matches.get(i)?.candidate_id;
|
||||
entries.iter().find(|entry| entry.path.id == id).cloned()
|
||||
}
|
||||
|
|
Some files were not shown because too many files have changed in this diff Show more
Loading…
Add table
Add a link
Reference in a new issue