Truncate description in tab title when it is too long
This commit is contained in:
parent
07d269234f
commit
fd5cb02ea9
3 changed files with 9 additions and 4 deletions
|
@ -35,6 +35,7 @@ use gpui::{
|
||||||
};
|
};
|
||||||
use highlight_matching_bracket::refresh_matching_bracket_highlights;
|
use highlight_matching_bracket::refresh_matching_bracket_highlights;
|
||||||
use hover_popover::{hide_hover, HoverState};
|
use hover_popover::{hide_hover, HoverState};
|
||||||
|
pub use items::MAX_TAB_TITLE_LEN;
|
||||||
pub use language::{char_kind, CharKind};
|
pub use language::{char_kind, CharKind};
|
||||||
use language::{
|
use language::{
|
||||||
BracketPair, Buffer, CodeAction, CodeLabel, Completion, Diagnostic, DiagnosticSeverity,
|
BracketPair, Buffer, CodeAction, CodeLabel, Completion, Diagnostic, DiagnosticSeverity,
|
||||||
|
|
|
@ -23,6 +23,7 @@ use util::TryFutureExt;
|
||||||
use workspace::{FollowableItem, Item, ItemHandle, ItemNavHistory, ProjectItem, StatusItemView};
|
use workspace::{FollowableItem, Item, ItemHandle, ItemNavHistory, ProjectItem, StatusItemView};
|
||||||
|
|
||||||
pub const FORMAT_TIMEOUT: Duration = Duration::from_secs(2);
|
pub const FORMAT_TIMEOUT: Duration = Duration::from_secs(2);
|
||||||
|
pub const MAX_TAB_TITLE_LEN: usize = 24;
|
||||||
|
|
||||||
impl FollowableItem for Editor {
|
impl FollowableItem for Editor {
|
||||||
fn from_state_proto(
|
fn from_state_proto(
|
||||||
|
@ -320,9 +321,14 @@ impl Item for Editor {
|
||||||
)
|
)
|
||||||
.with_children(detail.and_then(|detail| {
|
.with_children(detail.and_then(|detail| {
|
||||||
let path = path_for_buffer(&self.buffer, detail, false, cx)?;
|
let path = path_for_buffer(&self.buffer, detail, false, cx)?;
|
||||||
|
let description = path.to_string_lossy();
|
||||||
Some(
|
Some(
|
||||||
Label::new(
|
Label::new(
|
||||||
path.to_string_lossy().into(),
|
if description.len() > MAX_TAB_TITLE_LEN {
|
||||||
|
description[..MAX_TAB_TITLE_LEN].to_string() + "…"
|
||||||
|
} else {
|
||||||
|
description.into()
|
||||||
|
},
|
||||||
style.description.text.clone(),
|
style.description.text.clone(),
|
||||||
)
|
)
|
||||||
.contained()
|
.contained()
|
||||||
|
|
|
@ -4,7 +4,7 @@ use crate::{
|
||||||
ToggleWholeWord,
|
ToggleWholeWord,
|
||||||
};
|
};
|
||||||
use collections::HashMap;
|
use collections::HashMap;
|
||||||
use editor::{Anchor, Autoscroll, Editor, MultiBuffer, SelectAll};
|
use editor::{Anchor, Autoscroll, Editor, MultiBuffer, SelectAll, MAX_TAB_TITLE_LEN};
|
||||||
use gpui::{
|
use gpui::{
|
||||||
actions, elements::*, platform::CursorStyle, Action, AppContext, ElementBox, Entity,
|
actions, elements::*, platform::CursorStyle, Action, AppContext, ElementBox, Entity,
|
||||||
ModelContext, ModelHandle, MutableAppContext, RenderContext, Subscription, Task, View,
|
ModelContext, ModelHandle, MutableAppContext, RenderContext, Subscription, Task, View,
|
||||||
|
@ -26,8 +26,6 @@ use workspace::{
|
||||||
|
|
||||||
actions!(project_search, [Deploy, SearchInNew, ToggleFocus]);
|
actions!(project_search, [Deploy, SearchInNew, ToggleFocus]);
|
||||||
|
|
||||||
const MAX_TAB_TITLE_LEN: usize = 24;
|
|
||||||
|
|
||||||
#[derive(Default)]
|
#[derive(Default)]
|
||||||
struct ActiveSearches(HashMap<WeakModelHandle<Project>, WeakViewHandle<ProjectSearchView>>);
|
struct ActiveSearches(HashMap<WeakModelHandle<Project>, WeakViewHandle<ProjectSearchView>>);
|
||||||
|
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue