editor: Add ToggleFocus action (#34495)
This PR adds action `editor: toggle focus` which focuses to last active editor pane item in workspace. Release Notes: - Added `editor: toggle focus` action, which focuses to last active editor pane item. --------- Co-authored-by: Danilo Leal <daniloleal09@gmail.com>
This commit is contained in:
parent
572d3d637a
commit
0ada4ce900
3 changed files with 36 additions and 0 deletions
|
@ -356,6 +356,7 @@ pub fn init(cx: &mut App) {
|
|||
workspace.register_action(Editor::new_file_vertical);
|
||||
workspace.register_action(Editor::new_file_horizontal);
|
||||
workspace.register_action(Editor::cancel_language_server_work);
|
||||
workspace.register_action(Editor::toggle_focus);
|
||||
},
|
||||
)
|
||||
.detach();
|
||||
|
@ -16954,6 +16955,18 @@ impl Editor {
|
|||
cx.notify();
|
||||
}
|
||||
|
||||
pub fn toggle_focus(
|
||||
workspace: &mut Workspace,
|
||||
_: &actions::ToggleFocus,
|
||||
window: &mut Window,
|
||||
cx: &mut Context<Workspace>,
|
||||
) {
|
||||
let Some(item) = workspace.recent_active_item_by_type::<Self>(cx) else {
|
||||
return;
|
||||
};
|
||||
workspace.activate_item(&item, true, true, window, cx);
|
||||
}
|
||||
|
||||
pub fn toggle_fold(
|
||||
&mut self,
|
||||
_: &actions::ToggleFold,
|
||||
|
|
Loading…
Add table
Add a link
Reference in a new issue