Skip to content

armgit / zed

Public Imported from GitHub
0

Code at the speed of thought – Zed is a high-performance, multiplayer code editor from the creators of Atom and Tree-sitter.

editor: Add ToggleTabBar action (#12499)

Andrew Lyginf476a8bc2ac4
diff --git a/crates/editor/src/actions.rs b/crates/editor/src/actions.rs
index f2835d41542..e2a2c4d04f9 100644
--- a/crates/editor/src/actions.rs
+++ b/crates/editor/src/actions.rs
@@ -289,6 +289,7 @@ gpui::actions!(
ToggleLineNumbers,
ToggleIndentGuides,
ToggleSoftWrap,
+ ToggleTabBar,
Transpose,
Undo,
UndoSelection,
diff --git a/crates/editor/src/editor.rs b/crates/editor/src/editor.rs
index e5bfbf53924..601d0d47a5a 100644
--- a/crates/editor/src/editor.rs
+++ b/crates/editor/src/editor.rs
@@ -111,7 +111,7 @@ use rpc::{proto::*, ErrorExt};
use scroll::{Autoscroll, OngoingScroll, ScrollAnchor, ScrollManager, ScrollbarAutoHide};
use selections_collection::{resolve_multiple, MutableSelectionsCollection, SelectionsCollection};
use serde::{Deserialize, Serialize};
-use settings::{Settings, SettingsStore};
+use settings::{update_settings_file, Settings, SettingsStore};
use smallvec::SmallVec;
use snippet::Snippet;
use std::ops::Not as _;
@@ -143,7 +143,7 @@ use workspace::notifications::{DetachAndPromptErr, NotificationId};
use workspace::{
searchable::SearchEvent, ItemNavHistory, SplitDirection, ViewId, Workspace, WorkspaceId,
};
-use workspace::{OpenInTerminal, OpenTerminal, Toast};
+use workspace::{OpenInTerminal, OpenTerminal, TabBarSettings, Toast};
use crate::hover_links::find_url;
@@ -9800,6 +9800,17 @@ impl Editor {
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>) {
let currently_enabled = self.should_show_indent_guides().unwrap_or_else(|| {
self.buffer
diff --git a/crates/editor/src/element.rs b/crates/editor/src/element.rs
index 873d031393c..4df00228555 100644
--- a/crates/editor/src/element.rs
+++ b/crates/editor/src/element.rs
@@ -318,6 +318,7 @@ impl EditorElement {
register_action(view, cx, Editor::open_excerpts);
register_action(view, cx, Editor::open_excerpts_in_split);
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_indent_guides);
register_action(view, cx, Editor::toggle_inlay_hints);