fix: deduplicate selection/copy block in repl_render.rs#129
Conversation
…_view draw_chat and draw_child_view each independently computed text selection bounds, painted highlight cells into frame.buffer_mut(), and (when pending_copy was set) called copy_osc52 to write the selection to the clipboard -- the same ~60-line block duplicated verbatim between the two functions. Extract the shared logic into render_selection_and_copy(frame, inner, selection, scroll_offset, wrapped_text) and have both draw_chat and draw_child_view call it. Behavior is unchanged; this is a pure deduplication.
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@codex review |
|
You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard. |
|
@codex review — retrying, previous review attempt hit the Codex usage-limit error. |
|
Codex Review: Didn't find any major issues. Breezy! Reviewed commit: ℹ️ About Codex in GitHubYour team has set up Codex to review pull requests in this repo. Reviews are triggered when you
If Codex has suggestions, it will comment; otherwise it will react with 👍. Codex can also answer questions or update the PR. Try commenting "@codex address that feedback". |
Summary
draw_chatanddraw_child_viewincrates/tui/src/repl_render.rseach independently computed text-selection bounds, painted highlight cells intoframe.buffer_mut(), and (whenpending_copywas set) calledcopy_osc52to write the selection to the clipboard -- the same ~60-line block duplicated verbatim between the two functions.render_selection_and_copy(frame, inner, selection, scroll_offset, wrapped_text), and updated bothdraw_chatanddraw_child_viewto call it instead of maintaining their own copies.Test plan
cargo build -p acrawl-tui(compiles cleanly, no new imports beyond re-exportingSelectionStatefromrepl_app)cargo fmt -p acrawl-tuicargo test -p acrawl-tui(all tests pass, including selection-rendering related tests)cargo clippy -p acrawl-tui --all-targets -- -D warnings(clean)draw_chat'sscroll_off = state.list_state.offset()anddraw_child_view'sscroll_offset(from the child tab's list state) are still each computed by their own caller and passed into the shared helper, preserving per-view scroll semantics