debugger: Truncate long session and thread names (#33790)
Related to #33072 Release Notes: - debugger: Fixed long session and thread names eating up excessive space in the control strip.
This commit is contained in:
parent
4fdda8d5a1
commit
f9bd54b4b1
2 changed files with 10 additions and 0 deletions
|
@ -4,6 +4,7 @@ use collections::HashMap;
|
||||||
use gpui::{Animation, AnimationExt as _, Entity, Transformation, percentage};
|
use gpui::{Animation, AnimationExt as _, Entity, Transformation, percentage};
|
||||||
use project::debugger::session::{ThreadId, ThreadStatus};
|
use project::debugger::session::{ThreadId, ThreadStatus};
|
||||||
use ui::{ContextMenu, DropdownMenu, DropdownStyle, Indicator, prelude::*};
|
use ui::{ContextMenu, DropdownMenu, DropdownStyle, Indicator, prelude::*};
|
||||||
|
use util::truncate_and_trailoff;
|
||||||
|
|
||||||
use crate::{
|
use crate::{
|
||||||
debugger_panel::DebugPanel,
|
debugger_panel::DebugPanel,
|
||||||
|
@ -12,6 +13,8 @@ use crate::{
|
||||||
|
|
||||||
impl DebugPanel {
|
impl DebugPanel {
|
||||||
fn dropdown_label(label: impl Into<SharedString>) -> Label {
|
fn dropdown_label(label: impl Into<SharedString>) -> Label {
|
||||||
|
const MAX_LABEL_CHARS: usize = 50;
|
||||||
|
let label = truncate_and_trailoff(&label.into(), MAX_LABEL_CHARS);
|
||||||
Label::new(label).size(LabelSize::Small)
|
Label::new(label).size(LabelSize::Small)
|
||||||
}
|
}
|
||||||
|
|
||||||
|
@ -170,6 +173,8 @@ impl DebugPanel {
|
||||||
window: &mut Window,
|
window: &mut Window,
|
||||||
cx: &mut Context<Self>,
|
cx: &mut Context<Self>,
|
||||||
) -> Option<DropdownMenu> {
|
) -> Option<DropdownMenu> {
|
||||||
|
const MAX_LABEL_CHARS: usize = 150;
|
||||||
|
|
||||||
let running_state = running_state.clone();
|
let running_state = running_state.clone();
|
||||||
let running_state_read = running_state.read(cx);
|
let running_state_read = running_state.read(cx);
|
||||||
let thread_id = running_state_read.thread_id();
|
let thread_id = running_state_read.thread_id();
|
||||||
|
@ -202,6 +207,7 @@ impl DebugPanel {
|
||||||
.is_empty()
|
.is_empty()
|
||||||
.then(|| format!("Tid: {}", thread.id))
|
.then(|| format!("Tid: {}", thread.id))
|
||||||
.unwrap_or_else(|| thread.name);
|
.unwrap_or_else(|| thread.name);
|
||||||
|
let entry_name = truncate_and_trailoff(&entry_name, MAX_LABEL_CHARS);
|
||||||
|
|
||||||
this = this.entry(entry_name, None, move |window, cx| {
|
this = this.entry(entry_name, None, move |window, cx| {
|
||||||
running_state.update(cx, |running_state, cx| {
|
running_state.update(cx, |running_state, cx| {
|
||||||
|
|
|
@ -12,6 +12,7 @@ use rpc::proto;
|
||||||
use running::RunningState;
|
use running::RunningState;
|
||||||
use std::{cell::OnceCell, sync::OnceLock};
|
use std::{cell::OnceCell, sync::OnceLock};
|
||||||
use ui::{Indicator, Tooltip, prelude::*};
|
use ui::{Indicator, Tooltip, prelude::*};
|
||||||
|
use util::truncate_and_trailoff;
|
||||||
use workspace::{
|
use workspace::{
|
||||||
CollaboratorId, FollowableItem, ViewId, Workspace,
|
CollaboratorId, FollowableItem, ViewId, Workspace,
|
||||||
item::{self, Item},
|
item::{self, Item},
|
||||||
|
@ -126,7 +127,10 @@ impl DebugSession {
|
||||||
}
|
}
|
||||||
|
|
||||||
pub(crate) fn label_element(&self, depth: usize, cx: &App) -> AnyElement {
|
pub(crate) fn label_element(&self, depth: usize, cx: &App) -> AnyElement {
|
||||||
|
const MAX_LABEL_CHARS: usize = 150;
|
||||||
|
|
||||||
let label = self.label(cx);
|
let label = self.label(cx);
|
||||||
|
let label = truncate_and_trailoff(&label, MAX_LABEL_CHARS);
|
||||||
|
|
||||||
let is_terminated = self
|
let is_terminated = self
|
||||||
.running_state
|
.running_state
|
||||||
|
|
Loading…
Add table
Add a link
Reference in a new issue