Auto-fix clippy::collapsible_if violations (#36428)

Release Notes:

- N/A
This commit is contained in:
Piotr Osiewicz 2025-08-19 15:27:24 +02:00 committed by GitHub
parent 9e8ec72bd5
commit 8f567383e4
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
281 changed files with 6628 additions and 7089 deletions

View file

@ -305,15 +305,14 @@ impl Dock {
.detach();
cx.observe_in(&dock, window, move |workspace, dock, window, cx| {
if dock.read(cx).is_open() {
if let Some(panel) = dock.read(cx).active_panel() {
if panel.is_zoomed(window, cx) {
workspace.zoomed = Some(panel.to_any().downgrade());
workspace.zoomed_position = Some(position);
cx.emit(Event::ZoomChanged);
return;
}
}
if dock.read(cx).is_open()
&& let Some(panel) = dock.read(cx).active_panel()
&& panel.is_zoomed(window, cx)
{
workspace.zoomed = Some(panel.to_any().downgrade());
workspace.zoomed_position = Some(position);
cx.emit(Event::ZoomChanged);
return;
}
if workspace.zoomed_position == Some(position) {
workspace.zoomed = None;
@ -541,10 +540,10 @@ impl Dock {
Ok(ix) => ix,
Err(ix) => ix,
};
if let Some(active_index) = self.active_panel_index.as_mut() {
if *active_index >= index {
*active_index += 1;
}
if let Some(active_index) = self.active_panel_index.as_mut()
&& *active_index >= index
{
*active_index += 1;
}
self.panel_entries.insert(
index,
@ -566,16 +565,16 @@ impl Dock {
pub fn restore_state(&mut self, window: &mut Window, cx: &mut Context<Self>) -> bool {
if let Some(serialized) = self.serialized_dock.clone() {
if let Some(active_panel) = serialized.active_panel.filter(|_| serialized.visible) {
if let Some(idx) = self.panel_index_for_persistent_name(active_panel.as_str(), cx) {
self.activate_panel(idx, window, cx);
}
if let Some(active_panel) = serialized.active_panel.filter(|_| serialized.visible)
&& let Some(idx) = self.panel_index_for_persistent_name(active_panel.as_str(), cx)
{
self.activate_panel(idx, window, cx);
}
if serialized.zoom {
if let Some(panel) = self.active_panel() {
panel.set_zoomed(true, window, cx)
}
if serialized.zoom
&& let Some(panel) = self.active_panel()
{
panel.set_zoomed(true, window, cx)
}
self.set_open(serialized.visible, window, cx);
return true;

View file

@ -101,11 +101,11 @@ impl HistoryManager {
}
let mut deleted_ids = Vec::new();
for idx in (0..self.history.len()).rev() {
if let Some(entry) = self.history.get(idx) {
if user_removed.contains(&entry.path) {
deleted_ids.push(entry.id);
self.history.remove(idx);
}
if let Some(entry) = self.history.get(idx)
&& user_removed.contains(&entry.path)
{
deleted_ids.push(entry.id);
self.history.remove(idx);
}
}
cx.spawn(async move |_| {

View file

@ -832,10 +832,10 @@ impl<T: Item> ItemHandle for Entity<T> {
if let Some(item) = item.to_followable_item_handle(cx) {
let leader_id = workspace.leader_for_pane(&pane);
if let Some(leader_id) = leader_id {
if let Some(FollowEvent::Unfollow) = item.to_follow_event(event) {
workspace.unfollow(leader_id, window, cx);
}
if let Some(leader_id) = leader_id
&& let Some(FollowEvent::Unfollow) = item.to_follow_event(event)
{
workspace.unfollow(leader_id, window, cx);
}
if item.item_focus_handle(cx).contains_focused(window, cx) {
@ -863,10 +863,10 @@ impl<T: Item> ItemHandle for Entity<T> {
}
}
if let Some(item) = item.to_serializable_item_handle(cx) {
if item.should_serialize(event, cx) {
workspace.enqueue_item_serialization(item).ok();
}
if let Some(item) = item.to_serializable_item_handle(cx)
&& item.should_serialize(event, cx)
{
workspace.enqueue_item_serialization(item).ok();
}
T::to_item_events(event, |event| match event {
@ -948,11 +948,11 @@ impl<T: Item> ItemHandle for Entity<T> {
&self.read(cx).focus_handle(cx),
window,
move |workspace, window, cx| {
if let Some(item) = weak_item.upgrade() {
if item.workspace_settings(cx).autosave == AutosaveSetting::OnFocusChange {
Pane::autosave_item(&item, workspace.project.clone(), window, cx)
.detach_and_log_err(cx);
}
if let Some(item) = weak_item.upgrade()
&& item.workspace_settings(cx).autosave == AutosaveSetting::OnFocusChange
{
Pane::autosave_item(&item, workspace.project.clone(), window, cx)
.detach_and_log_err(cx);
}
},
)

View file

@ -141,10 +141,10 @@ impl ModalLayer {
}
if let Some(active_modal) = self.active_modal.take() {
if let Some(previous_focus) = active_modal.previous_focus_handle {
if active_modal.focus_handle.contains_focused(window, cx) {
previous_focus.focus(window);
}
if let Some(previous_focus) = active_modal.previous_focus_handle
&& active_modal.focus_handle.contains_focused(window, cx)
{
previous_focus.focus(window);
}
cx.notify();
}

View file

@ -580,19 +580,18 @@ impl Pane {
// or focus the active item itself
if let Some(weak_last_focus_handle) =
self.last_focus_handle_by_item.get(&active_item.item_id())
&& let Some(focus_handle) = weak_last_focus_handle.upgrade()
{
if let Some(focus_handle) = weak_last_focus_handle.upgrade() {
focus_handle.focus(window);
return;
}
focus_handle.focus(window);
return;
}
active_item.item_focus_handle(cx).focus(window);
} else if let Some(focused) = window.focused(cx) {
if !self.context_menu_focused(window, cx) {
self.last_focus_handle_by_item
.insert(active_item.item_id(), focused.downgrade());
}
} else if let Some(focused) = window.focused(cx)
&& !self.context_menu_focused(window, cx)
{
self.last_focus_handle_by_item
.insert(active_item.item_id(), focused.downgrade());
}
}
}
@ -858,10 +857,11 @@ impl Pane {
}
pub fn handle_item_edit(&mut self, item_id: EntityId, cx: &App) {
if let Some(preview_item) = self.preview_item() {
if preview_item.item_id() == item_id && !preview_item.preserve_preview(cx) {
self.set_preview_item_id(None, cx);
}
if let Some(preview_item) = self.preview_item()
&& preview_item.item_id() == item_id
&& !preview_item.preserve_preview(cx)
{
self.set_preview_item_id(None, cx);
}
}
@ -900,12 +900,12 @@ impl Pane {
if let Some((index, existing_item)) = existing_item {
// If the item is already open, and the item is a preview item
// and we are not allowing items to open as preview, mark the item as persistent.
if let Some(preview_item_id) = self.preview_item_id {
if let Some(tab) = self.items.get(index) {
if tab.item_id() == preview_item_id && !allow_preview {
self.set_preview_item_id(None, cx);
}
}
if let Some(preview_item_id) = self.preview_item_id
&& let Some(tab) = self.items.get(index)
&& tab.item_id() == preview_item_id
&& !allow_preview
{
self.set_preview_item_id(None, cx);
}
if activate {
self.activate_item(index, focus_item, focus_item, window, cx);
@ -977,21 +977,21 @@ impl Pane {
self.close_items_on_item_open(window, cx);
}
if item.is_singleton(cx) {
if let Some(&entry_id) = item.project_entry_ids(cx).first() {
let Some(project) = self.project.upgrade() else {
return;
};
if item.is_singleton(cx)
&& let Some(&entry_id) = item.project_entry_ids(cx).first()
{
let Some(project) = self.project.upgrade() else {
return;
};
let project = project.read(cx);
if let Some(project_path) = project.path_for_entry(entry_id, cx) {
let abs_path = project.absolute_path(&project_path, cx);
self.nav_history
.0
.lock()
.paths_by_item
.insert(item.item_id(), (project_path, abs_path));
}
let project = project.read(cx);
if let Some(project_path) = project.path_for_entry(entry_id, cx) {
let abs_path = project.absolute_path(&project_path, cx);
self.nav_history
.0
.lock()
.paths_by_item
.insert(item.item_id(), (project_path, abs_path));
}
}
// If no destination index is specified, add or move the item after the
@ -1192,12 +1192,11 @@ impl Pane {
use NavigationMode::{GoingBack, GoingForward};
if index < self.items.len() {
let prev_active_item_ix = mem::replace(&mut self.active_item_index, index);
if prev_active_item_ix != self.active_item_index
|| matches!(self.nav_history.mode(), GoingBack | GoingForward)
if (prev_active_item_ix != self.active_item_index
|| matches!(self.nav_history.mode(), GoingBack | GoingForward))
&& let Some(prev_item) = self.items.get(prev_active_item_ix)
{
if let Some(prev_item) = self.items.get(prev_active_item_ix) {
prev_item.deactivated(window, cx);
}
prev_item.deactivated(window, cx);
}
self.update_history(index);
self.update_toolbar(window, cx);
@ -2462,10 +2461,11 @@ impl Pane {
.on_mouse_down(
MouseButton::Left,
cx.listener(move |pane, event: &MouseDownEvent, _, cx| {
if let Some(id) = pane.preview_item_id {
if id == item_id && event.click_count > 1 {
pane.set_preview_item_id(None, cx);
}
if let Some(id) = pane.preview_item_id
&& id == item_id
&& event.click_count > 1
{
pane.set_preview_item_id(None, cx);
}
}),
)
@ -3048,18 +3048,18 @@ impl Pane {
window: &mut Window,
cx: &mut Context<Self>,
) {
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
if let ControlFlow::Break(()) = custom_drop_handle(self, dragged_tab, window, cx) {
return;
}
if let Some(custom_drop_handle) = self.custom_drop_handle.clone()
&& let ControlFlow::Break(()) = custom_drop_handle(self, dragged_tab, window, cx)
{
return;
}
let mut to_pane = cx.entity();
let split_direction = self.drag_split_direction;
let item_id = dragged_tab.item.item_id();
if let Some(preview_item_id) = self.preview_item_id {
if item_id == preview_item_id {
self.set_preview_item_id(None, cx);
}
if let Some(preview_item_id) = self.preview_item_id
&& item_id == preview_item_id
{
self.set_preview_item_id(None, cx);
}
let is_clone = cfg!(target_os = "macos") && window.modifiers().alt
@ -3136,11 +3136,10 @@ impl Pane {
window: &mut Window,
cx: &mut Context<Self>,
) {
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
if let ControlFlow::Break(()) = custom_drop_handle(self, dragged_selection, window, cx)
{
return;
}
if let Some(custom_drop_handle) = self.custom_drop_handle.clone()
&& let ControlFlow::Break(()) = custom_drop_handle(self, dragged_selection, window, cx)
{
return;
}
self.handle_project_entry_drop(
&dragged_selection.active_selection.entry_id,
@ -3157,10 +3156,10 @@ impl Pane {
window: &mut Window,
cx: &mut Context<Self>,
) {
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
if let ControlFlow::Break(()) = custom_drop_handle(self, project_entry_id, window, cx) {
return;
}
if let Some(custom_drop_handle) = self.custom_drop_handle.clone()
&& let ControlFlow::Break(()) = custom_drop_handle(self, project_entry_id, window, cx)
{
return;
}
let mut to_pane = cx.entity();
let split_direction = self.drag_split_direction;
@ -3233,10 +3232,10 @@ impl Pane {
window: &mut Window,
cx: &mut Context<Self>,
) {
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
if let ControlFlow::Break(()) = custom_drop_handle(self, paths, window, cx) {
return;
}
if let Some(custom_drop_handle) = self.custom_drop_handle.clone()
&& let ControlFlow::Break(()) = custom_drop_handle(self, paths, window, cx)
{
return;
}
let mut to_pane = cx.entity();
let mut split_direction = self.drag_split_direction;
@ -3790,10 +3789,10 @@ impl NavHistory {
borrowed_history.paths_by_item.get(&entry.item.id())
{
f(entry, project_and_abs_path.clone());
} else if let Some(item) = entry.item.upgrade() {
if let Some(path) = item.project_path(cx) {
f(entry, (path, None));
}
} else if let Some(item) = entry.item.upgrade()
&& let Some(path) = item.project_path(cx)
{
f(entry, (path, None));
}
})
}

View file

@ -619,15 +619,15 @@ impl PaneAxis {
let mut found_axis_index: Option<usize> = None;
if !found_pane {
for (i, pa) in self.members.iter_mut().enumerate() {
if let Member::Axis(pa) = pa {
if let Some(done) = pa.resize(pane, axis, amount, bounds) {
if done {
return Some(true); // pane found and operations already done
} else if self.axis != axis {
return Some(false); // pane found but this is not the correct axis direction
} else {
found_axis_index = Some(i); // pane found and this is correct direction
}
if let Member::Axis(pa) = pa
&& let Some(done) = pa.resize(pane, axis, amount, bounds)
{
if done {
return Some(true); // pane found and operations already done
} else if self.axis != axis {
return Some(false); // pane found but this is not the correct axis direction
} else {
found_axis_index = Some(i); // pane found and this is correct direction
}
}
}
@ -743,13 +743,13 @@ impl PaneAxis {
let bounding_boxes = self.bounding_boxes.lock();
for (idx, member) in self.members.iter().enumerate() {
if let Some(coordinates) = bounding_boxes[idx] {
if coordinates.contains(&coordinate) {
return match member {
Member::Pane(found) => Some(found),
Member::Axis(axis) => axis.pane_at_pixel_position(coordinate),
};
}
if let Some(coordinates) = bounding_boxes[idx]
&& coordinates.contains(&coordinate)
{
return match member {
Member::Pane(found) => Some(found),
Member::Axis(axis) => axis.pane_at_pixel_position(coordinate),
};
}
}
None
@ -1273,17 +1273,18 @@ mod element {
window.paint_quad(gpui::fill(overlay_bounds, overlay_background));
}
if let Some(border) = overlay_border {
if self.active_pane_ix == Some(ix) && child.is_leaf_pane {
window.paint_quad(gpui::quad(
overlay_bounds,
0.,
gpui::transparent_black(),
border,
cx.theme().colors().border_selected,
BorderStyle::Solid,
));
}
if let Some(border) = overlay_border
&& self.active_pane_ix == Some(ix)
&& child.is_leaf_pane
{
window.paint_quad(gpui::quad(
overlay_bounds,
0.,
gpui::transparent_black(),
border,
cx.theme().colors().border_selected,
BorderStyle::Solid,
));
}
}

View file

@ -1345,18 +1345,18 @@ impl Workspace {
.timer(Duration::from_millis(100))
.await;
this.update_in(cx, |this, window, cx| {
if let Some(display) = window.display(cx) {
if let Ok(display_uuid) = display.uuid() {
let window_bounds = window.inner_window_bounds();
if let Some(database_id) = workspace_id {
cx.background_executor()
.spawn(DB.set_window_open_status(
database_id,
SerializedWindowBounds(window_bounds),
display_uuid,
))
.detach_and_log_err(cx);
}
if let Some(display) = window.display(cx)
&& let Ok(display_uuid) = display.uuid()
{
let window_bounds = window.inner_window_bounds();
if let Some(database_id) = workspace_id {
cx.background_executor()
.spawn(DB.set_window_open_status(
database_id,
SerializedWindowBounds(window_bounds),
display_uuid,
))
.detach_and_log_err(cx);
}
}
this.bounds_save_task_queued.take();
@ -1729,13 +1729,12 @@ impl Workspace {
let item_map: HashMap<EntityId, &Box<dyn ItemHandle>> =
pane.items().map(|item| (item.item_id(), item)).collect();
for entry in pane.activation_history() {
if entry.timestamp > recent_timestamp {
if let Some(&item) = item_map.get(&entry.entity_id) {
if let Some(typed_item) = item.act_as::<T>(cx) {
recent_timestamp = entry.timestamp;
recent_item = Some(typed_item);
}
}
if entry.timestamp > recent_timestamp
&& let Some(&item) = item_map.get(&entry.entity_id)
&& let Some(typed_item) = item.act_as::<T>(cx)
{
recent_timestamp = entry.timestamp;
recent_item = Some(typed_item);
}
}
}
@ -1774,19 +1773,19 @@ impl Workspace {
}
});
if let Some(item) = pane.active_item() {
if let Some(project_path) = item.project_path(cx) {
let fs_path = self.project.read(cx).absolute_path(&project_path, cx);
if let Some(item) = pane.active_item()
&& let Some(project_path) = item.project_path(cx)
{
let fs_path = self.project.read(cx).absolute_path(&project_path, cx);
if let Some(fs_path) = &fs_path {
abs_paths_opened
.entry(fs_path.clone())
.or_default()
.insert(project_path.clone());
}
history.insert(project_path, (fs_path, std::usize::MAX));
if let Some(fs_path) = &fs_path {
abs_paths_opened
.entry(fs_path.clone())
.or_default()
.insert(project_path.clone());
}
history.insert(project_path, (fs_path, std::usize::MAX));
}
}
@ -2250,29 +2249,28 @@ impl Workspace {
.count()
})?;
if let Some(active_call) = active_call {
if close_intent != CloseIntent::Quit
&& workspace_count == 1
&& active_call.read_with(cx, |call, _| call.room().is_some())?
{
let answer = cx.update(|window, cx| {
window.prompt(
PromptLevel::Warning,
"Do you want to leave the current call?",
None,
&["Close window and hang up", "Cancel"],
cx,
)
})?;
if let Some(active_call) = active_call
&& close_intent != CloseIntent::Quit
&& workspace_count == 1
&& active_call.read_with(cx, |call, _| call.room().is_some())?
{
let answer = cx.update(|window, cx| {
window.prompt(
PromptLevel::Warning,
"Do you want to leave the current call?",
None,
&["Close window and hang up", "Cancel"],
cx,
)
})?;
if answer.await.log_err() == Some(1) {
return anyhow::Ok(false);
} else {
active_call
.update(cx, |call, cx| call.hang_up(cx))?
.await
.log_err();
}
if answer.await.log_err() == Some(1) {
return anyhow::Ok(false);
} else {
active_call
.update(cx, |call, cx| call.hang_up(cx))?
.await
.log_err();
}
}
@ -2448,10 +2446,10 @@ impl Workspace {
for (pane, item) in dirty_items {
let (singleton, project_entry_ids) =
cx.update(|_, cx| (item.is_singleton(cx), item.project_entry_ids(cx)))?;
if singleton || !project_entry_ids.is_empty() {
if !Pane::save_item(project.clone(), &pane, &*item, save_intent, cx).await? {
return Ok(false);
}
if (singleton || !project_entry_ids.is_empty())
&& !Pane::save_item(project.clone(), &pane, &*item, save_intent, cx).await?
{
return Ok(false);
}
}
Ok(true)
@ -3080,14 +3078,12 @@ impl Workspace {
let mut focus_center = false;
for dock in self.all_docks() {
dock.update(cx, |dock, cx| {
if Some(dock.position()) != dock_to_reveal {
if let Some(panel) = dock.active_panel() {
if panel.is_zoomed(window, cx) {
focus_center |=
panel.panel_focus_handle(cx).contains_focused(window, cx);
dock.set_open(false, window, cx);
}
}
if Some(dock.position()) != dock_to_reveal
&& let Some(panel) = dock.active_panel()
&& panel.is_zoomed(window, cx)
{
focus_center |= panel.panel_focus_handle(cx).contains_focused(window, cx);
dock.set_open(false, window, cx);
}
});
}
@ -3328,10 +3324,10 @@ impl Workspace {
.downgrade()
});
if let Member::Pane(center_pane) = &self.center.root {
if center_pane.read(cx).items_len() == 0 {
return self.open_path(path, Some(pane), true, window, cx);
}
if let Member::Pane(center_pane) = &self.center.root
&& center_pane.read(cx).items_len() == 0
{
return self.open_path(path, Some(pane), true, window, cx);
}
let project_path = path.into();
@ -3393,10 +3389,10 @@ impl Workspace {
if let Some(entry_id) = entry_id {
item = pane.read(cx).item_for_entry(entry_id, cx);
}
if item.is_none() {
if let Some(project_path) = project_path {
item = pane.read(cx).item_for_path(project_path, cx);
}
if item.is_none()
&& let Some(project_path) = project_path
{
item = pane.read(cx).item_for_path(project_path, cx);
}
item.and_then(|item| item.downcast::<T>())
@ -3440,12 +3436,11 @@ impl Workspace {
let item_id = item.item_id();
let mut destination_index = None;
pane.update(cx, |pane, cx| {
if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation {
if let Some(preview_item_id) = pane.preview_item_id() {
if preview_item_id != item_id {
destination_index = pane.close_current_preview_item(window, cx);
}
}
if PreviewTabsSettings::get_global(cx).enable_preview_from_code_navigation
&& let Some(preview_item_id) = pane.preview_item_id()
&& preview_item_id != item_id
{
destination_index = pane.close_current_preview_item(window, cx);
}
pane.set_preview_item_id(Some(item.item_id()), cx)
});
@ -3912,10 +3907,10 @@ impl Workspace {
pane::Event::RemovedItem { item } => {
cx.emit(Event::ActiveItemChanged);
self.update_window_edited(window, cx);
if let hash_map::Entry::Occupied(entry) = self.panes_by_item.entry(item.item_id()) {
if entry.get().entity_id() == pane.entity_id() {
entry.remove();
}
if let hash_map::Entry::Occupied(entry) = self.panes_by_item.entry(item.item_id())
&& entry.get().entity_id() == pane.entity_id()
{
entry.remove();
}
}
pane::Event::Focus => {
@ -4105,14 +4100,13 @@ impl Workspace {
pub fn focused_pane(&self, window: &Window, cx: &App) -> Entity<Pane> {
for dock in self.all_docks() {
if dock.focus_handle(cx).contains_focused(window, cx) {
if let Some(pane) = dock
if dock.focus_handle(cx).contains_focused(window, cx)
&& let Some(pane) = dock
.read(cx)
.active_panel()
.and_then(|panel| panel.pane(cx))
{
return pane;
}
{
return pane;
}
}
self.active_pane().clone()
@ -4393,10 +4387,10 @@ impl Workspace {
title.push_str("");
}
if let Some(last_title) = self.last_window_title.as_ref() {
if &title == last_title {
return;
}
if let Some(last_title) = self.last_window_title.as_ref()
&& &title == last_title
{
return;
}
window.set_window_title(&title);
self.last_window_title = Some(title);
@ -4575,10 +4569,8 @@ impl Workspace {
}
})??;
if should_add_view {
if let Some(view) = update_active_view.view {
Self::add_view_from_leader(this.clone(), leader_id, &view, cx).await?
}
if should_add_view && let Some(view) = update_active_view.view {
Self::add_view_from_leader(this.clone(), leader_id, &view, cx).await?
}
}
proto::update_followers::Variant::UpdateView(update_view) => {
@ -4774,40 +4766,40 @@ impl Workspace {
if window.is_window_active() {
let (active_item, panel_id) = self.active_item_for_followers(window, cx);
if let Some(item) = active_item {
if item.item_focus_handle(cx).contains_focused(window, cx) {
let leader_id = self
.pane_for(&*item)
.and_then(|pane| self.leader_for_pane(&pane));
let leader_peer_id = match leader_id {
Some(CollaboratorId::PeerId(peer_id)) => Some(peer_id),
Some(CollaboratorId::Agent) | None => None,
};
if let Some(item) = active_item
&& item.item_focus_handle(cx).contains_focused(window, cx)
{
let leader_id = self
.pane_for(&*item)
.and_then(|pane| self.leader_for_pane(&pane));
let leader_peer_id = match leader_id {
Some(CollaboratorId::PeerId(peer_id)) => Some(peer_id),
Some(CollaboratorId::Agent) | None => None,
};
if let Some(item) = item.to_followable_item_handle(cx) {
let id = item
.remote_id(&self.app_state.client, window, cx)
.map(|id| id.to_proto());
if let Some(item) = item.to_followable_item_handle(cx) {
let id = item
.remote_id(&self.app_state.client, window, cx)
.map(|id| id.to_proto());
if let Some(id) = id {
if let Some(variant) = item.to_state_proto(window, cx) {
let view = Some(proto::View {
id: id.clone(),
leader_id: leader_peer_id,
variant: Some(variant),
panel_id: panel_id.map(|id| id as i32),
});
if let Some(id) = id
&& let Some(variant) = item.to_state_proto(window, cx)
{
let view = Some(proto::View {
id: id.clone(),
leader_id: leader_peer_id,
variant: Some(variant),
panel_id: panel_id.map(|id| id as i32),
});
is_project_item = item.is_project_item(window, cx);
update = proto::UpdateActiveView {
view,
// TODO: Remove after version 0.145.x stabilizes.
id,
leader_id: leader_peer_id,
};
}
is_project_item = item.is_project_item(window, cx);
update = proto::UpdateActiveView {
view,
// TODO: Remove after version 0.145.x stabilizes.
id,
leader_id: leader_peer_id,
};
}
};
}
}
}
@ -4832,16 +4824,14 @@ impl Workspace {
let mut active_item = None;
let mut panel_id = None;
for dock in self.all_docks() {
if dock.focus_handle(cx).contains_focused(window, cx) {
if let Some(panel) = dock.read(cx).active_panel() {
if let Some(pane) = panel.pane(cx) {
if let Some(item) = pane.read(cx).active_item() {
active_item = Some(item);
panel_id = panel.remote_id();
break;
}
}
}
if dock.focus_handle(cx).contains_focused(window, cx)
&& let Some(panel) = dock.read(cx).active_panel()
&& let Some(pane) = panel.pane(cx)
&& let Some(item) = pane.read(cx).active_item()
{
active_item = Some(item);
panel_id = panel.remote_id();
break;
}
}
@ -4969,10 +4959,10 @@ impl Workspace {
let state = self.follower_states.get(&peer_id.into())?;
let mut item_to_activate = None;
if let (Some(active_view_id), true) = (state.active_view_id, leader_in_this_app) {
if let Some(item) = state.items_by_leader_view_id.get(&active_view_id) {
if leader_in_this_project || !item.view.is_project_item(window, cx) {
item_to_activate = Some((item.location, item.view.boxed_clone()));
}
if let Some(item) = state.items_by_leader_view_id.get(&active_view_id)
&& (leader_in_this_project || !item.view.is_project_item(window, cx))
{
item_to_activate = Some((item.location, item.view.boxed_clone()));
}
} else if let Some(shared_screen) =
self.shared_screen_for_peer(peer_id, &state.center_pane, window, cx)
@ -6079,10 +6069,10 @@ fn open_items(
project_paths_to_open
.iter_mut()
.for_each(|(_, project_path)| {
if let Some(project_path_to_open) = project_path {
if restored_project_paths.contains(project_path_to_open) {
*project_path = None;
}
if let Some(project_path_to_open) = project_path
&& restored_project_paths.contains(project_path_to_open)
{
*project_path = None;
}
});
} else {
@ -6109,24 +6099,24 @@ fn open_items(
// We only want to open file paths here. If one of the items
// here is a directory, it was already opened further above
// with a `find_or_create_worktree`.
if let Ok(task) = abs_path_task {
if task.await.map_or(true, |p| p.is_file()) {
return Some((
ix,
workspace
.update_in(cx, |workspace, window, cx| {
workspace.open_path(
file_project_path,
None,
true,
window,
cx,
)
})
.log_err()?
.await,
));
}
if let Ok(task) = abs_path_task
&& task.await.map_or(true, |p| p.is_file())
{
return Some((
ix,
workspace
.update_in(cx, |workspace, window, cx| {
workspace.open_path(
file_project_path,
None,
true,
window,
cx,
)
})
.log_err()?
.await,
));
}
None
})
@ -6728,10 +6718,10 @@ impl WorkspaceStore {
.update(cx, |workspace, window, cx| {
let handler_response =
workspace.handle_follow(follower.project_id, window, cx);
if let Some(active_view) = handler_response.active_view.clone() {
if workspace.project.read(cx).remote_id() == follower.project_id {
response.active_view = Some(active_view)
}
if let Some(active_view) = handler_response.active_view.clone()
&& workspace.project.read(cx).remote_id() == follower.project_id
{
response.active_view = Some(active_view)
}
})
.is_ok()
@ -6965,34 +6955,35 @@ async fn join_channel_internal(
}
// If you are the first to join a channel, see if you should share your project.
if room.remote_participants().is_empty() && !room.local_participant_is_guest() {
if let Some(workspace) = requesting_window {
let project = workspace.update(cx, |workspace, _, cx| {
let project = workspace.project.read(cx);
if room.remote_participants().is_empty()
&& !room.local_participant_is_guest()
&& let Some(workspace) = requesting_window
{
let project = workspace.update(cx, |workspace, _, cx| {
let project = workspace.project.read(cx);
if !CallSettings::get_global(cx).share_on_join {
return None;
}
if (project.is_local() || project.is_via_ssh())
&& project.visible_worktrees(cx).any(|tree| {
tree.read(cx)
.root_entry()
.map_or(false, |entry| entry.is_dir())
})
{
Some(workspace.project.clone())
} else {
None
}
});
if let Ok(Some(project)) = project {
return Some(cx.spawn(async move |room, cx| {
room.update(cx, |room, cx| room.share_project(project, cx))?
.await?;
Ok(())
}));
if !CallSettings::get_global(cx).share_on_join {
return None;
}
if (project.is_local() || project.is_via_ssh())
&& project.visible_worktrees(cx).any(|tree| {
tree.read(cx)
.root_entry()
.map_or(false, |entry| entry.is_dir())
})
{
Some(workspace.project.clone())
} else {
None
}
});
if let Ok(Some(project)) = project {
return Some(cx.spawn(async move |room, cx| {
room.update(cx, |room, cx| room.share_project(project, cx))?
.await?;
Ok(())
}));
}
}
@ -7189,35 +7180,35 @@ pub fn open_paths(
}
})?;
if open_options.open_new_workspace.is_none() && existing.is_none() {
if all_metadatas.iter().all(|file| !file.is_dir) {
cx.update(|cx| {
if let Some(window) = cx
.active_window()
.and_then(|window| window.downcast::<Workspace>())
{
if let Ok(workspace) = window.read(cx) {
let project = workspace.project().read(cx);
if project.is_local() && !project.is_via_collab() {
existing = Some(window);
open_visible = OpenVisible::None;
return;
}
}
if open_options.open_new_workspace.is_none()
&& existing.is_none()
&& all_metadatas.iter().all(|file| !file.is_dir)
{
cx.update(|cx| {
if let Some(window) = cx
.active_window()
.and_then(|window| window.downcast::<Workspace>())
&& let Ok(workspace) = window.read(cx)
{
let project = workspace.project().read(cx);
if project.is_local() && !project.is_via_collab() {
existing = Some(window);
open_visible = OpenVisible::None;
return;
}
for window in local_workspace_windows(cx) {
if let Ok(workspace) = window.read(cx) {
let project = workspace.project().read(cx);
if project.is_via_collab() {
continue;
}
existing = Some(window);
open_visible = OpenVisible::None;
break;
}
for window in local_workspace_windows(cx) {
if let Ok(workspace) = window.read(cx) {
let project = workspace.project().read(cx);
if project.is_via_collab() {
continue;
}
existing = Some(window);
open_visible = OpenVisible::None;
break;
}
})?;
}
}
})?;
}
}
@ -7651,10 +7642,9 @@ pub fn reload(cx: &mut App) {
for window in workspace_windows {
if let Ok(should_close) = window.update(cx, |workspace, window, cx| {
workspace.prepare_to_close(CloseIntent::Quit, window, cx)
}) {
if !should_close.await? {
return Ok(());
}
}) && !should_close.await?
{
return Ok(());
}
}
cx.update(|cx| cx.restart())

View file

@ -282,19 +282,17 @@ impl Settings for WorkspaceSettings {
if vscode
.read_bool("accessibility.dimUnfocused.enabled")
.unwrap_or_default()
{
if let Some(opacity) = vscode
&& let Some(opacity) = vscode
.read_value("accessibility.dimUnfocused.opacity")
.and_then(|v| v.as_f64())
{
if let Some(settings) = current.active_pane_modifiers.as_mut() {
settings.inactive_opacity = Some(opacity as f32)
} else {
current.active_pane_modifiers = Some(ActivePanelModifiers {
inactive_opacity: Some(opacity as f32),
..Default::default()
})
}
{
if let Some(settings) = current.active_pane_modifiers.as_mut() {
settings.inactive_opacity = Some(opacity as f32)
} else {
current.active_pane_modifiers = Some(ActivePanelModifiers {
inactive_opacity: Some(opacity as f32),
..Default::default()
})
}
}
@ -345,13 +343,11 @@ impl Settings for WorkspaceSettings {
.read_value("workbench.editor.limit.value")
.and_then(|v| v.as_u64())
.and_then(|n| NonZeroUsize::new(n as usize))
{
if vscode
&& vscode
.read_bool("workbench.editor.limit.enabled")
.unwrap_or_default()
{
current.max_tabs = Some(n)
}
{
current.max_tabs = Some(n)
}
// some combination of "window.restoreWindows" and "workbench.startupEditor" might