mirror of
https://github.com/openai/codex.git
synced 2026-05-01 20:02:05 +03:00
@@ -416,8 +416,8 @@ impl BottomPane {
|
||||
self.request_redraw();
|
||||
}
|
||||
|
||||
pub(crate) fn set_unified_exec_sessions(&mut self, sessions: Vec<String>) {
|
||||
if self.unified_exec_footer.set_sessions(sessions) {
|
||||
pub(crate) fn set_unified_exec_processes(&mut self, processes: Vec<String>) {
|
||||
if self.unified_exec_footer.set_processes(processes) {
|
||||
self.request_redraw();
|
||||
}
|
||||
}
|
||||
|
||||
@@ -8,34 +8,34 @@ use crate::live_wrap::take_prefix_by_width;
|
||||
use crate::render::renderable::Renderable;
|
||||
|
||||
pub(crate) struct UnifiedExecFooter {
|
||||
sessions: Vec<String>,
|
||||
processes: Vec<String>,
|
||||
}
|
||||
|
||||
impl UnifiedExecFooter {
|
||||
pub(crate) fn new() -> Self {
|
||||
Self {
|
||||
sessions: Vec::new(),
|
||||
processes: Vec::new(),
|
||||
}
|
||||
}
|
||||
|
||||
pub(crate) fn set_sessions(&mut self, sessions: Vec<String>) -> bool {
|
||||
if self.sessions == sessions {
|
||||
pub(crate) fn set_processes(&mut self, processes: Vec<String>) -> bool {
|
||||
if self.processes == processes {
|
||||
return false;
|
||||
}
|
||||
self.sessions = sessions;
|
||||
self.processes = processes;
|
||||
true
|
||||
}
|
||||
|
||||
pub(crate) fn is_empty(&self) -> bool {
|
||||
self.sessions.is_empty()
|
||||
self.processes.is_empty()
|
||||
}
|
||||
|
||||
fn render_lines(&self, width: u16) -> Vec<Line<'static>> {
|
||||
if self.sessions.is_empty() || width < 4 {
|
||||
if self.processes.is_empty() || width < 4 {
|
||||
return Vec::new();
|
||||
}
|
||||
|
||||
let count = self.sessions.len();
|
||||
let count = self.processes.len();
|
||||
let plural = if count == 1 { "" } else { "s" };
|
||||
let message = format!(" {count} background terminal{plural} running · /ps to view");
|
||||
let (truncated, _, _) = take_prefix_by_width(&message, width as usize);
|
||||
@@ -72,7 +72,7 @@ mod tests {
|
||||
#[test]
|
||||
fn render_more_sessions() {
|
||||
let mut footer = UnifiedExecFooter::new();
|
||||
footer.set_sessions(vec!["rg \"foo\" src".to_string()]);
|
||||
footer.set_processes(vec!["rg \"foo\" src".to_string()]);
|
||||
let width = 50;
|
||||
let height = footer.desired_height(width);
|
||||
let mut buf = Buffer::empty(Rect::new(0, 0, width, height));
|
||||
@@ -83,7 +83,7 @@ mod tests {
|
||||
#[test]
|
||||
fn render_many_sessions() {
|
||||
let mut footer = UnifiedExecFooter::new();
|
||||
footer.set_sessions((0..123).map(|idx| format!("cmd {idx}")).collect());
|
||||
footer.set_processes((0..123).map(|idx| format!("cmd {idx}")).collect());
|
||||
let width = 50;
|
||||
let height = footer.desired_height(width);
|
||||
let mut buf = Buffer::empty(Rect::new(0, 0, width, height));
|
||||
|
||||
Reference in New Issue
Block a user