Skip to content
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
44 changes: 19 additions & 25 deletions codex-rs/tui/src/bottom_pane/mentions_v2/render.rs
Original file line number Diff line number Diff line change
Expand Up @@ -9,8 +9,7 @@ use ratatui::text::Span;
use ratatui::widgets::Widget;

use crate::line_truncation::truncate_line_with_ellipsis_if_overflow;
use crate::render::Insets;
use crate::render::RectExt;
use crate::style::accent_style;

use super::candidate::MentionType;
use super::candidate::SearchResult;
Expand Down Expand Up @@ -46,15 +45,7 @@ pub(super) fn render_popup(
(area, None)
};

render_rows(
list_area.inset(Insets::tlbr(
/*top*/ 0, /*left*/ 2, /*bottom*/ 0, /*right*/ 0,
)),
buf,
rows,
state,
empty_message,
);
render_rows(list_area, buf, rows, state, empty_message);

if let Some(hint_area) = hint_area {
let hint_area = Rect {
Expand All @@ -78,7 +69,7 @@ fn render_rows(
return;
}
if rows.is_empty() {
Line::from(empty_message.italic()).render(area, buf);
Line::from(vec![" ".into(), empty_message.italic()]).render(area, buf);
return;
}

Expand Down Expand Up @@ -131,31 +122,34 @@ fn build_line(
width: usize,
primary_column_width: usize,
) -> Line<'static> {
let base_style = if selected {
Style::default().bold()
} else {
Style::default()
};
let dim_style = if selected {
Style::default().bold()
} else {
Style::default().dim()
};
let base_style = Style::default();
let dim_style = Style::default().dim();
let tag = row.mention_type.span(base_style);
let tag_width = tag.width();
let content_width = width.saturating_sub(tag_width.saturating_add(2));
let gutter = if selected { "> " } else { " " };
let gutter_width = gutter.len();
let content_width =
width.saturating_sub(gutter_width.saturating_add(tag_width).saturating_add(2));
let content = truncate_line_with_ellipsis_if_overflow(
content_line(row, base_style, dim_style, primary_column_width),
content_width,
);
let rendered_content_width = content.width();
let mut spans = Vec::new();
let mut spans = vec![gutter.into()];
spans.extend(content.spans);
let padding = width.saturating_sub(rendered_content_width.saturating_add(tag_width));
let padding = width.saturating_sub(
gutter_width
.saturating_add(rendered_content_width)
.saturating_add(tag_width),
);
if padding > 0 {
spans.push(" ".repeat(padding).set_style(dim_style));
}
spans.push(tag);
if selected {
let style = accent_style();
spans.iter_mut().for_each(|span| span.style = style);
}

Line::from(spans)
}
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -5,7 +5,7 @@ expression: terminal.backend()
" "
"› @sa "
" "
" Sample Plugin Plugin with skills and an MCP server Plugin"
"> Sample Plugin Plugin with skills and an MCP server Plugin"
" "
" "
" "
Expand Down
Loading