mirror of
https://github.com/openai/codex.git
synced 2026-05-01 11:52:10 +03:00
use markdown for rendering tips (#7557)
## Summary - render tooltip content through the markdown renderer and prepend a bold Tip label - wrap tooltips at the available width using the indent’s measured width before adding the indent ## Testing - `/root/.cargo/bin/just fmt` - `RUSTFLAGS="--cfg tokio_unstable" TOKIO_UNSTABLE=1 /root/.cargo/bin/just fix -p codex-tui` *(fails: codex-tui tests reference tokio::time::advance/start_paused gated behind the tokio test-util feature)* - `RUSTFLAGS="--cfg tokio_unstable" TOKIO_UNSTABLE=1 cargo test -p codex-tui` *(fails: codex-tui tests reference tokio::time::advance/start_paused gated behind the tokio test-util feature)* ------ [Codex Task](https://chatgpt.com/codex/tasks/task_i_693081406050832c9772ae9fa5dd77ca)
This commit is contained in:
@@ -573,18 +573,19 @@ impl TooltipHistoryCell {
|
||||
|
||||
impl HistoryCell for TooltipHistoryCell {
|
||||
fn display_lines(&self, width: u16) -> Vec<Line<'static>> {
|
||||
let indent: Line<'static> = " ".into();
|
||||
let mut lines = Vec::new();
|
||||
let tooltip_line: Line<'static> = vec!["Tip: ".cyan(), self.tip.into()].into();
|
||||
let wrap_opts = RtOptions::new(usize::from(width.max(1)))
|
||||
.initial_indent(indent.clone())
|
||||
.subsequent_indent(indent.clone());
|
||||
lines.extend(
|
||||
word_wrap_line(&tooltip_line, wrap_opts.clone())
|
||||
.into_iter()
|
||||
.map(|line| line_to_static(&line)),
|
||||
let indent = " ";
|
||||
let indent_width = UnicodeWidthStr::width(indent);
|
||||
let wrap_width = usize::from(width.max(1))
|
||||
.saturating_sub(indent_width)
|
||||
.max(1);
|
||||
let mut lines: Vec<Line<'static>> = Vec::new();
|
||||
append_markdown(
|
||||
&format!("**Tip:** {}", self.tip),
|
||||
Some(wrap_width),
|
||||
&mut lines,
|
||||
);
|
||||
lines
|
||||
|
||||
prefix_lines(lines, indent.into(), indent.into())
|
||||
}
|
||||
}
|
||||
|
||||
|
||||
Reference in New Issue
Block a user