Skip to content

Conversation

@Octane0411
Copy link

Fix: TUI single-line paste cursor position

Description

This PR fixes a bug where pasting single-line text in the TUI prompt would incorrectly move the cursor to the end of the input buffer, instead of placing it immediately after the pasted text.

Issue

Fixes #7210

Changes

  • Removed input.gotoBufferEnd() from the onPaste handler in opencode/packages/opencode/src/cli/cmd/tui/component/prompt/index.tsx.

Verification

  • Verified that input.gotoBufferEnd() was the cause of the cursor jump.
  • The default behavior of the textarea component handles cursor positioning correctly for pasted text.
  • Retained markDirty() and requestRender() to ensure UI updates correctly after paste.

@github-actions
Copy link
Contributor

github-actions bot commented Jan 8, 2026

The following comment was made by an LLM, it may be inaccurate:

No duplicate PRs found

@Octane0411
Copy link
Author

Hi @thdxr, this is a small fix for the cursor jumping issue reported in #7210.

Root Cause:
I've confirmed this was a regression introduced in #6070 (commit 2806f24). The input.gotoBufferEnd() call was added to handle resizing but inadvertently forces the cursor to the end for all paste operations.

Fix:
My change removes the unnecessary cursor jump while preserving the layout update logic (markDirty / requestRender), ensuring the textarea still resizes correctly without disrupting the cursor position.

Demo
Before (Bug)

Kapture.2026-01-08.at.16.41.12.mp4

After (Fixed)

Kapture.2026-01-08.at.16.43.25.mp4

Ready for review when you have a chance. Thanks!

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.

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

1 participant