Skip to content

CLI composer cursor drifts after pasting tabs #15146

@zzho325

Description

@zzho325

What version of Codex CLI is running?

codex-cli 0.115.0

What subscription do you have?

Company-managed Codex account

Which model were you using?

gpt-5.4

What platform is your computer?

Darwin 25.3.0 arm64 arm

What terminal emulator and version are you using (if applicable)?

tmux (TERM=screen-256color); underlying terminal host unknown

What issue are you seeing?

In the TUI composer, pasting text with tab characters can leave the cursor visually offset from the rendered text.

For example, after pasting a string like \t\tabc, the tabs do not appear in the rendered composer text, but the cursor still advances as if the tabs were present. That leaves the cursor too far to the right relative to the visible abc.

This looks like a mismatch between rendering and cursor-position math rather than a generic paste failure.

What steps can reproduce the bug?

  1. Open Codex CLI TUI.
  2. Focus the composer/input box.
  3. Paste text containing leading tabs, for example \t\tabc.
  4. Observe the rendered text and cursor position.

What is the expected behavior?

Rendered text and cursor position should stay aligned. If tabs are not rendered, they also should not advance the cursor position.

Additional information

I did not find an existing GitHub issue covering this exact case.

Likely root-cause direction:

  • the composer cursor math uses unicode-width on the raw textarea string
  • ratatui drops control characters like \t during buffer rendering

That would explain why the tabs disappear visually but still affect cursor placement.

Metadata

Metadata

Assignees

No one assigned

    Labels

    TUIIssues related to the terminal user interface: text input, menus and dialogs, and terminal displaybugSomething isn't working

    Type

    No type
    No fields configured for issues without a type.

    Projects

    No projects

    Milestone

    No milestone

    Relationships

    None yet

    Development

    No branches or pull requests

    Issue actions