mirror of
https://github.com/openai/codex.git
synced 2026-11-10 21:00:47 +00:00
## Why RPC sending and waiting do not depend on request or response types, and Markdown layout does not depend on the parser iterator. Share these implementations across typed calls and parser variants. ## What changed - Extract `RpcClient::send_request_and_wait` into a non-generic async method, preserving registration before serialization and disconnected-client error precedence. - Remove the iterator type parameter from `Writer` and pass iterators to event traversal methods, retaining static dispatch and dropping the parser before rendering state, including on unwind. - Update streaming rendering and existing rendering tests to use the separate parser. GitOrigin-RevId: 4cc07223111b7c08211028948d13fe04598f8fc7
32 lines
1.2 KiB
Rust
32 lines
1.2 KiB
Rust
//! Task-list checkboxes replace unordered bullets and retain ordered numbering.
|
|
//! Keep the hanging indent aligned with the task text, including in loose lists.
|
|
|
|
use super::Writer;
|
|
use ratatui::text::Span;
|
|
|
|
impl Writer<'_, '_> {
|
|
pub(super) fn task_list_marker(&mut self, checked: bool) {
|
|
let Some(context) = self
|
|
.indent_stack
|
|
.iter_mut()
|
|
.rev()
|
|
.find(|context| context.is_list)
|
|
else {
|
|
return;
|
|
};
|
|
if let Some(marker) = context.marker.as_mut()
|
|
&& let Some(span) = marker.last_mut()
|
|
{
|
|
let prefix = span.content.strip_suffix("• ").unwrap_or(&span.content);
|
|
let checkbox = if checked { "☑" } else { "☐" };
|
|
span.content = format!("{prefix}{checkbox} ").into();
|
|
context.prefix = vec![Span::from(" ".repeat(Self::spans_display_width(marker)))];
|
|
}
|
|
if self.current_line_content.is_some() {
|
|
// Loose lists start their paragraph before the task marker arrives.
|
|
self.current_initial_indent = self.prefix_spans(/*pending_marker_line*/ true);
|
|
self.current_subsequent_indent = self.prefix_spans(/*pending_marker_line*/ false);
|
|
}
|
|
}
|
|
}
|