Skip to content

fix: deduplicate selection/copy block in repl_render.rs#129

Open
Mingye-Lu wants to merge 1 commit into
mainfrom
fix/dedupe-selection-copy
Open

fix: deduplicate selection/copy block in repl_render.rs#129
Mingye-Lu wants to merge 1 commit into
mainfrom
fix/dedupe-selection-copy

Conversation

@Mingye-Lu

Copy link
Copy Markdown
Owner

Summary

  • draw_chat and draw_child_view in crates/tui/src/repl_render.rs 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.
  • Extracted the shared logic into a new private helper, render_selection_and_copy(frame, inner, selection, scroll_offset, wrapped_text), and updated both draw_chat and draw_child_view to call it instead of maintaining their own copies.
  • Pure deduplication: no behavior change. The clipboard side effect intentionally stays in the render path, matching the existing behavior (not moving it is out of scope for this fix).

Test plan

  • cargo build -p acrawl-tui (compiles cleanly, no new imports beyond re-exporting SelectionState from repl_app)
  • cargo fmt -p acrawl-tui
  • cargo test -p acrawl-tui (all tests pass, including selection-rendering related tests)
  • cargo clippy -p acrawl-tui --all-targets -- -D warnings (clean)
  • Manual read-through confirming draw_chat's scroll_off = state.list_state.offset() and draw_child_view's scroll_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

…_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.
@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@Mingye-Lu

Copy link
Copy Markdown
Owner Author

@codex review

@chatgpt-codex-connector

Copy link
Copy Markdown

You have reached your Codex usage limits for code reviews. You can see your limits in the Codex usage dashboard.
To continue using code reviews, you can upgrade your account or add credits to your account and enable them for code reviews in your settings.

@Mingye-Lu

Copy link
Copy Markdown
Owner Author

@codex review — retrying, previous review attempt hit the Codex usage-limit error.

@chatgpt-codex-connector

Copy link
Copy Markdown

Codex Review: Didn't find any major issues. Breezy!

Reviewed commit: ec286dd272

ℹ️ About Codex in GitHub

Your team has set up Codex to review pull requests in this repo. Reviews are triggered when you

  • Open a pull request for review
  • Mark a draft as ready
  • Comment "@codex review".

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".

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant