Cleanups preparing for WindowContext refactor (#22475)

* Remove unnecessary WindowContext and ViewContext '_ lifetimes

* Removed some cases where WindowContext has a different name than `cx`.

Release Notes:

- N/A
This commit is contained in:
Michael Sloan 2024-12-28 14:36:14 -07:00 committed by GitHub
parent 9815358bdd
commit 016b5d60e1
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
41 changed files with 127 additions and 152 deletions

View file

@ -1942,7 +1942,7 @@ impl Pane {
}
}
fn toggle_pin_tab(&mut self, _: &TogglePinTab, cx: &mut ViewContext<'_, Self>) {
fn toggle_pin_tab(&mut self, _: &TogglePinTab, cx: &mut ViewContext<Self>) {
if self.items.is_empty() {
return;
}
@ -1954,7 +1954,7 @@ impl Pane {
}
}
fn pin_tab_at(&mut self, ix: usize, cx: &mut ViewContext<'_, Self>) {
fn pin_tab_at(&mut self, ix: usize, cx: &mut ViewContext<Self>) {
maybe!({
let pane = cx.view().clone();
let destination_index = self.pinned_tab_count.min(ix);
@ -1971,7 +1971,7 @@ impl Pane {
});
}
fn unpin_tab_at(&mut self, ix: usize, cx: &mut ViewContext<'_, Self>) {
fn unpin_tab_at(&mut self, ix: usize, cx: &mut ViewContext<Self>) {
maybe!({
let pane = cx.view().clone();
self.pinned_tab_count = self.pinned_tab_count.checked_sub(1)?;
@ -2003,7 +2003,7 @@ impl Pane {
item: &dyn ItemHandle,
detail: usize,
focus_handle: &FocusHandle,
cx: &mut ViewContext<'_, Pane>,
cx: &mut ViewContext<Pane>,
) -> impl IntoElement {
let is_active = ix == self.active_item_index;
let is_preview = self
@ -2416,7 +2416,7 @@ impl Pane {
})
}
fn render_tab_bar(&mut self, cx: &mut ViewContext<'_, Pane>) -> impl IntoElement {
fn render_tab_bar(&mut self, cx: &mut ViewContext<Pane>) -> impl IntoElement {
let focus_handle = self.focus_handle.clone();
let navigate_backward = IconButton::new("navigate_backward", IconName::ArrowLeft)
.icon_size(IconSize::Small)
@ -2592,12 +2592,7 @@ impl Pane {
}
}
fn handle_tab_drop(
&mut self,
dragged_tab: &DraggedTab,
ix: usize,
cx: &mut ViewContext<'_, Self>,
) {
fn handle_tab_drop(&mut self, dragged_tab: &DraggedTab, ix: usize, cx: &mut ViewContext<Self>) {
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
if let ControlFlow::Break(()) = custom_drop_handle(self, dragged_tab, cx) {
return;
@ -2663,7 +2658,7 @@ impl Pane {
&mut self,
dragged_selection: &DraggedSelection,
dragged_onto: Option<usize>,
cx: &mut ViewContext<'_, Self>,
cx: &mut ViewContext<Self>,
) {
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
if let ControlFlow::Break(()) = custom_drop_handle(self, dragged_selection, cx) {
@ -2681,7 +2676,7 @@ impl Pane {
&mut self,
project_entry_id: &ProjectEntryId,
target: Option<usize>,
cx: &mut ViewContext<'_, Self>,
cx: &mut ViewContext<Self>,
) {
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
if let ControlFlow::Break(()) = custom_drop_handle(self, project_entry_id, cx) {
@ -2746,11 +2741,7 @@ impl Pane {
.log_err();
}
fn handle_external_paths_drop(
&mut self,
paths: &ExternalPaths,
cx: &mut ViewContext<'_, Self>,
) {
fn handle_external_paths_drop(&mut self, paths: &ExternalPaths, cx: &mut ViewContext<Self>) {
if let Some(custom_drop_handle) = self.custom_drop_handle.clone() {
if let ControlFlow::Break(()) = custom_drop_handle(self, paths, cx) {
return;

View file

@ -11,7 +11,7 @@ pub fn schedule_task(
task_to_resolve: &TaskTemplate,
task_cx: &TaskContext,
omit_history: bool,
cx: &mut ViewContext<'_, Workspace>,
cx: &mut ViewContext<Workspace>,
) {
match workspace.project.read(cx).ssh_connection_state(cx) {
None | Some(ConnectionState::Connected) => {}
@ -44,7 +44,7 @@ pub fn schedule_resolved_task(
task_source_kind: TaskSourceKind,
mut resolved_task: ResolvedTask,
omit_history: bool,
cx: &mut ViewContext<'_, Workspace>,
cx: &mut ViewContext<Workspace>,
) {
if let Some(spawn_in_terminal) = resolved_task.resolved.take() {
if !omit_history {

View file

@ -1706,11 +1706,11 @@ impl Workspace {
cx.defer(|cx| {
cx.windows().iter().find(|window| {
window
.update(cx, |_, window| {
if window.is_window_active() {
.update(cx, |_, cx| {
if cx.is_window_active() {
//This can only get called when the window's project connection has been lost
//so we don't need to prompt the user for anything and instead just close the window
window.remove_window();
cx.remove_window();
true
} else {
false
@ -4561,7 +4561,7 @@ impl Workspace {
div
}
pub fn has_active_modal(&self, cx: &WindowContext<'_>) -> bool {
pub fn has_active_modal(&self, cx: &WindowContext) -> bool {
self.modal_layer.read(cx).has_active_modal()
}
@ -5018,7 +5018,7 @@ impl Render for Workspace {
fn resize_bottom_dock(
new_size: Pixels,
workspace: &mut Workspace,
cx: &mut ViewContext<'_, Workspace>,
cx: &mut ViewContext<Workspace>,
) {
let size = new_size.min(workspace.bounds.bottom() - RESIZE_HANDLE_SIZE);
workspace.bottom_dock.update(cx, |bottom_dock, cx| {
@ -5026,22 +5026,14 @@ fn resize_bottom_dock(
});
}
fn resize_right_dock(
new_size: Pixels,
workspace: &mut Workspace,
cx: &mut ViewContext<'_, Workspace>,
) {
fn resize_right_dock(new_size: Pixels, workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) {
let size = new_size.max(workspace.bounds.left() - RESIZE_HANDLE_SIZE);
workspace.right_dock.update(cx, |right_dock, cx| {
right_dock.resize_active_panel(Some(size), cx);
});
}
fn resize_left_dock(
new_size: Pixels,
workspace: &mut Workspace,
cx: &mut ViewContext<'_, Workspace>,
) {
fn resize_left_dock(new_size: Pixels, workspace: &mut Workspace, cx: &mut ViewContext<Workspace>) {
let size = new_size.min(workspace.bounds.right() - RESIZE_HANDLE_SIZE);
workspace.left_dock.update(cx, |left_dock, cx| {
@ -6149,7 +6141,7 @@ fn resize_edge(
}
}
fn join_pane_into_active(active_pane: &View<Pane>, pane: &View<Pane>, cx: &mut WindowContext<'_>) {
fn join_pane_into_active(active_pane: &View<Pane>, pane: &View<Pane>, cx: &mut WindowContext) {
if pane == active_pane {
return;
} else if pane.read(cx).items_len() == 0 {
@ -6163,7 +6155,7 @@ fn join_pane_into_active(active_pane: &View<Pane>, pane: &View<Pane>, cx: &mut W
}
}
fn move_all_items(from_pane: &View<Pane>, to_pane: &View<Pane>, cx: &mut WindowContext<'_>) {
fn move_all_items(from_pane: &View<Pane>, to_pane: &View<Pane>, cx: &mut WindowContext) {
let destination_is_different = from_pane != to_pane;
let mut moved_items = 0;
for (item_ix, item_handle) in from_pane
@ -6195,7 +6187,7 @@ pub fn move_item(
destination: &View<Pane>,
item_id_to_move: EntityId,
destination_index: usize,
cx: &mut WindowContext<'_>,
cx: &mut WindowContext,
) {
let Some((item_ix, item_handle)) = source
.read(cx)
@ -6227,7 +6219,7 @@ pub fn move_active_item(
destination: &View<Pane>,
focus_destination: bool,
close_if_empty: bool,
cx: &mut WindowContext<'_>,
cx: &mut WindowContext,
) {
if source == destination {
return;