editor: Add ToggleTabBar action (#12499)
This PR adds the `editor: toggle tab bar` action that hides / shows the tab bar and updates the `tab_bar.show` setting in `settings.json` accordingly. First mentioned in https://github.com/zed-industries/zed/pull/7356#issuecomment-2118445379. Release Notes: - Added the `editor: toggle tab bar` action.
This commit is contained in:
parent
d3d0d01571
commit
f476a8bc2a
3 changed files with 15 additions and 2 deletions
|
@ -289,6 +289,7 @@ gpui::actions!(
|
||||||
ToggleLineNumbers,
|
ToggleLineNumbers,
|
||||||
ToggleIndentGuides,
|
ToggleIndentGuides,
|
||||||
ToggleSoftWrap,
|
ToggleSoftWrap,
|
||||||
|
ToggleTabBar,
|
||||||
Transpose,
|
Transpose,
|
||||||
Undo,
|
Undo,
|
||||||
UndoSelection,
|
UndoSelection,
|
||||||
|
|
|
@ -111,7 +111,7 @@ use rpc::{proto::*, ErrorExt};
|
||||||
use scroll::{Autoscroll, OngoingScroll, ScrollAnchor, ScrollManager, ScrollbarAutoHide};
|
use scroll::{Autoscroll, OngoingScroll, ScrollAnchor, ScrollManager, ScrollbarAutoHide};
|
||||||
use selections_collection::{resolve_multiple, MutableSelectionsCollection, SelectionsCollection};
|
use selections_collection::{resolve_multiple, MutableSelectionsCollection, SelectionsCollection};
|
||||||
use serde::{Deserialize, Serialize};
|
use serde::{Deserialize, Serialize};
|
||||||
use settings::{Settings, SettingsStore};
|
use settings::{update_settings_file, Settings, SettingsStore};
|
||||||
use smallvec::SmallVec;
|
use smallvec::SmallVec;
|
||||||
use snippet::Snippet;
|
use snippet::Snippet;
|
||||||
use std::ops::Not as _;
|
use std::ops::Not as _;
|
||||||
|
@ -143,7 +143,7 @@ use workspace::notifications::{DetachAndPromptErr, NotificationId};
|
||||||
use workspace::{
|
use workspace::{
|
||||||
searchable::SearchEvent, ItemNavHistory, SplitDirection, ViewId, Workspace, WorkspaceId,
|
searchable::SearchEvent, ItemNavHistory, SplitDirection, ViewId, Workspace, WorkspaceId,
|
||||||
};
|
};
|
||||||
use workspace::{OpenInTerminal, OpenTerminal, Toast};
|
use workspace::{OpenInTerminal, OpenTerminal, TabBarSettings, Toast};
|
||||||
|
|
||||||
use crate::hover_links::find_url;
|
use crate::hover_links::find_url;
|
||||||
|
|
||||||
|
@ -9800,6 +9800,17 @@ impl Editor {
|
||||||
cx.notify();
|
cx.notify();
|
||||||
}
|
}
|
||||||
|
|
||||||
|
pub fn toggle_tab_bar(&mut self, _: &ToggleTabBar, cx: &mut ViewContext<Self>) {
|
||||||
|
let Some(workspace) = self.workspace() else {
|
||||||
|
return;
|
||||||
|
};
|
||||||
|
let fs = workspace.read(cx).app_state().fs.clone();
|
||||||
|
let current_show = TabBarSettings::get_global(cx).show;
|
||||||
|
update_settings_file::<TabBarSettings>(fs, cx, move |setting| {
|
||||||
|
setting.show = Some(!current_show);
|
||||||
|
});
|
||||||
|
}
|
||||||
|
|
||||||
pub fn toggle_indent_guides(&mut self, _: &ToggleIndentGuides, cx: &mut ViewContext<Self>) {
|
pub fn toggle_indent_guides(&mut self, _: &ToggleIndentGuides, cx: &mut ViewContext<Self>) {
|
||||||
let currently_enabled = self.should_show_indent_guides().unwrap_or_else(|| {
|
let currently_enabled = self.should_show_indent_guides().unwrap_or_else(|| {
|
||||||
self.buffer
|
self.buffer
|
||||||
|
|
|
@ -318,6 +318,7 @@ impl EditorElement {
|
||||||
register_action(view, cx, Editor::open_excerpts);
|
register_action(view, cx, Editor::open_excerpts);
|
||||||
register_action(view, cx, Editor::open_excerpts_in_split);
|
register_action(view, cx, Editor::open_excerpts_in_split);
|
||||||
register_action(view, cx, Editor::toggle_soft_wrap);
|
register_action(view, cx, Editor::toggle_soft_wrap);
|
||||||
|
register_action(view, cx, Editor::toggle_tab_bar);
|
||||||
register_action(view, cx, Editor::toggle_line_numbers);
|
register_action(view, cx, Editor::toggle_line_numbers);
|
||||||
register_action(view, cx, Editor::toggle_indent_guides);
|
register_action(view, cx, Editor::toggle_indent_guides);
|
||||||
register_action(view, cx, Editor::toggle_inlay_hints);
|
register_action(view, cx, Editor::toggle_inlay_hints);
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue