TUI - single-line paste moves cursor to the end of input #4368

Closed
opened 2026-02-16 17:43:35 -05:00 by yindo · 3 comments
Owner

Originally created by @Nindaleth on GitHub (Jan 7, 2026).

Originally assigned to: @kommander on GitHub.

Description

When pasting into the TUI, the cursor is always moved to the end of the input box. This applies to both the initial input box that leads to creation of a new session, and its equivalent during conversation.

I guess the issue is somewhere in OpenTUI, but I don't have any other OpenTUI app to confirm.

Doesn't seem terminal-specific.

Plugins

obra/superpowers, @franlol/opencode-md-table-formatter@0.0.3

OpenCode version

1.1.4

Steps to reproduce

  1. Store a word in OS clipboard, for example "terminal". Anything will work as long as it's not multiline (which would trigger the "pasted N lines" block feature instead of pasting text directly).
  2. Manually enter multiple lines into the input so that it looks like this:
<cursor>line1
line2
line3
  1. Paste (both Shift+Insert and Ctrl+Shift+V do the same thing on my env)
  2. Observe unwanted cursor movement:
terminalline1
line2
line3<cursor>

Screenshot and/or share link

No response

Operating System

Linux Fedora 43

Terminal

Ghostty, Terminator

Originally created by @Nindaleth on GitHub (Jan 7, 2026). Originally assigned to: @kommander on GitHub. ### Description When pasting into the TUI, the cursor is always moved to the end of the input box. This applies to both the initial input box that leads to creation of a new session, and its equivalent during conversation. I guess the issue is somewhere in OpenTUI, but I don't have any other OpenTUI app to confirm. Doesn't seem terminal-specific. ### Plugins obra/superpowers, @franlol/opencode-md-table-formatter@0.0.3 ### OpenCode version 1.1.4 ### Steps to reproduce 1. Store a word in OS clipboard, for example "terminal". Anything will work as long as it's not multiline (which would trigger the "pasted N lines" block feature instead of pasting text directly). 2. Manually enter multiple lines into the input so that it looks like this: ``` <cursor>line1 line2 line3 ``` 3. Paste (both Shift+Insert and Ctrl+Shift+V do the same thing on my env) 4. Observe unwanted cursor movement: ``` terminalline1 line2 line3<cursor> ``` ### Screenshot and/or share link _No response_ ### Operating System Linux Fedora 43 ### Terminal Ghostty, Terminator
yindo added the opentuibug labels 2026-02-16 17:43:35 -05:00
yindo closed this issue 2026-02-16 17:43:35 -05:00
Author
Owner

@github-actions[bot] commented on GitHub (Jan 7, 2026):

This issue might be a duplicate of existing issues. Please check:

  • #3081: Paste issues in WSL (related paste/cursor issues)

Feel free to ignore if none of these address your specific case.

@github-actions[bot] commented on GitHub (Jan 7, 2026): This issue might be a duplicate of existing issues. Please check: - #3081: Paste issues in WSL (related paste/cursor issues) Feel free to ignore if none of these address your specific case.
Author
Owner

@kostrse commented on GitHub (Jan 8, 2026):

I consistently reproduce this on MacOS Ghostty

@kostrse commented on GitHub (Jan 8, 2026): I consistently reproduce this on MacOS Ghostty
Author
Owner

@Octane0411 commented on GitHub (Jan 8, 2026):

I've opened PR #7277 to fix this.

Root Cause:
The issue was introduced in PR #6070 (commit 2806f240). That PR added input.gotoBufferEnd() to the onPaste handler to ensure the textarea resized correctly, but it inadvertently forces the cursor to the end of the buffer even for single-line pastes.

My fix removes the unnecessary gotoBufferEnd() call while keeping the layout update logic (markDirty / requestRender), which solves the cursor jumping issue without breaking the resize behavior.

I also noticed @kostrse mentioned this happens on Ghostty as well — this fix should resolve it for all terminals.

@Octane0411 commented on GitHub (Jan 8, 2026): I've opened PR #7277 to fix this. **Root Cause:** The issue was introduced in PR #6070 (commit 2806f240). That PR added `input.gotoBufferEnd()` to the `onPaste` handler to ensure the textarea resized correctly, but it inadvertently forces the cursor to the end of the buffer even for single-line pastes. My fix removes the unnecessary `gotoBufferEnd()` call while keeping the layout update logic (`markDirty` / `requestRender`), which solves the cursor jumping issue without breaking the resize behavior. I also noticed @kostrse mentioned this happens on Ghostty as well — this fix should resolve it for all terminals.
Sign in to join this conversation.
1 Participants
Notifications
Due Date
No due date set.
Dependencies

No dependencies set.

Reference: anomalyco/opencode#4368