Fix layout for terminal tabs (#3514)

This PR fixes the layout for terminal tabs.

We need to use an `h_stack` here to get the icon and the label to
position themselves next to each other instead of one on top of the
other.

Release Notes:

- N/A
This commit is contained in:
Marshall Bowers 2023-12-06 14:28:31 -05:00 committed by GitHub
parent 2c350a71fe
commit 147c99f1a7
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
3 changed files with 8 additions and 6 deletions

1
Cargo.lock generated
View file

@ -9531,6 +9531,7 @@ dependencies = [
"terminal2", "terminal2",
"theme2", "theme2",
"thiserror", "thiserror",
"ui2",
"util", "util",
"workspace2", "workspace2",
] ]

View file

@ -21,6 +21,7 @@ workspace = { package = "workspace2", path = "../workspace2" }
db = { package = "db2", path = "../db2" } db = { package = "db2", path = "../db2" }
procinfo = { git = "https://github.com/zed-industries/wezterm", rev = "5cd757e5f2eb039ed0c6bb6512223e69d5efc64d", default-features = false } procinfo = { git = "https://github.com/zed-industries/wezterm", rev = "5cd757e5f2eb039ed0c6bb6512223e69d5efc64d", default-features = false }
terminal = { package = "terminal2", path = "../terminal2" } terminal = { package = "terminal2", path = "../terminal2" }
ui = { package = "ui2", path = "../ui2" }
smallvec.workspace = true smallvec.workspace = true
smol.workspace = true smol.workspace = true
mio-extras = "2.0.6" mio-extras = "2.0.6"

View file

@ -9,10 +9,9 @@ pub mod terminal_panel;
// use crate::terminal_element::TerminalElement; // use crate::terminal_element::TerminalElement;
use editor::{scroll::autoscroll::Autoscroll, Editor}; use editor::{scroll::autoscroll::Autoscroll, Editor};
use gpui::{ use gpui::{
actions, div, Action, AnyElement, AppContext, Div, Element, EventEmitter, FocusEvent, actions, div, Action, AnyElement, AppContext, Div, EventEmitter, FocusEvent, FocusHandle,
FocusHandle, Focusable, FocusableElement, FocusableView, InputHandler, InteractiveElement, Focusable, FocusableElement, FocusableView, InputHandler, KeyDownEvent, Keystroke, Model,
KeyDownEvent, Keystroke, Model, MouseButton, MouseDownEvent, ParentElement, Pixels, Render, MouseButton, MouseDownEvent, Pixels, Render, Task, View, VisualContext, WeakView,
SharedString, Styled, Task, View, ViewContext, VisualContext, WeakView, WindowContext,
}; };
use language::Bias; use language::Bias;
use persistence::TERMINAL_DB; use persistence::TERMINAL_DB;
@ -25,13 +24,13 @@ use terminal::{
terminal_settings::{TerminalBlink, TerminalSettings, WorkingDirectory}, terminal_settings::{TerminalBlink, TerminalSettings, WorkingDirectory},
Event, MaybeNavigationTarget, Terminal, Event, MaybeNavigationTarget, Terminal,
}; };
use ui::{h_stack, prelude::*, ContextMenu, Icon, IconElement, Label};
use util::{paths::PathLikeWithPosition, ResultExt}; use util::{paths::PathLikeWithPosition, ResultExt};
use workspace::{ use workspace::{
item::{BreadcrumbText, Item, ItemEvent}, item::{BreadcrumbText, Item, ItemEvent},
notifications::NotifyResultExt, notifications::NotifyResultExt,
register_deserializable_item, register_deserializable_item,
searchable::{SearchEvent, SearchOptions, SearchableItem}, searchable::{SearchEvent, SearchOptions, SearchableItem},
ui::{ContextMenu, Icon, IconElement, Label},
CloseActiveItem, NewCenterTerminal, Pane, ToolbarItemLocation, Workspace, WorkspaceId, CloseActiveItem, NewCenterTerminal, Pane, ToolbarItemLocation, Workspace, WorkspaceId,
}; };
@ -745,7 +744,8 @@ impl Item for TerminalView {
fn tab_content(&self, _detail: Option<usize>, cx: &WindowContext) -> AnyElement { fn tab_content(&self, _detail: Option<usize>, cx: &WindowContext) -> AnyElement {
let title = self.terminal().read(cx).title(); let title = self.terminal().read(cx).title();
div() h_stack()
.gap_2()
.child(IconElement::new(Icon::Terminal)) .child(IconElement::new(Icon::Terminal))
.child(Label::new(title)) .child(Label::new(title))
.into_any() .into_any()