Skip to content

Cursor position wrong after pasting multi-line text in prompt input #14840

@PrakharMNNIT

Description

@PrakharMNNIT

Bug

After pasting multi-line text into the prompt input, the cursor lands in the middle of the pasted text instead of at the end.

Root Cause

document.execCommand('insertText') creates <div> block elements for multi-line text. getCursorPosition() doesn't count implicit newlines at block boundaries, but parseFromDOM() does. This cursor/text mismatch causes the cursor to be positioned incorrectly after the editor re-renders.

Steps to Reproduce

  1. Copy multi-line text
  2. Paste into the prompt input
  3. Cursor lands in the middle instead of at the end

Metadata

Metadata

Assignees

Labels

opentuiThis relates to changes in v1.0, now that opencode uses opentui

Type

No type

Projects

No projects

Milestone

No milestone

Relationships

None yet

Development

No branches or pull requests

Issue actions