Merge pull request #546 from Kilo-Org/session/agent_8e672607-eb9d-4b31-8292-c18813a7a18d
fix(vscode): fix caret position desync after pasting text in chat input
This commit is contained in:
@@ -152,6 +152,17 @@ export const PromptInput: Component = () => {
|
|||||||
textareaRef.style.height = `${Math.min(textareaRef.scrollHeight, 200)}px`
|
textareaRef.style.height = `${Math.min(textareaRef.scrollHeight, 200)}px`
|
||||||
}
|
}
|
||||||
|
|
||||||
|
const handlePaste = (e: ClipboardEvent) => {
|
||||||
|
imageAttach.handlePaste(e)
|
||||||
|
// After pasting text, the textarea content changes but the layout may not
|
||||||
|
// have reflowed yet, causing the caret position to be visually out of sync.
|
||||||
|
// Defer height recalculation to after the browser completes the reflow.
|
||||||
|
requestAnimationFrame(() => {
|
||||||
|
adjustHeight()
|
||||||
|
syncHighlightScroll()
|
||||||
|
})
|
||||||
|
}
|
||||||
|
|
||||||
const handleInput = (e: InputEvent) => {
|
const handleInput = (e: InputEvent) => {
|
||||||
const target = e.target as HTMLTextAreaElement
|
const target = e.target as HTMLTextAreaElement
|
||||||
const val = target.value
|
const val = target.value
|
||||||
@@ -304,7 +315,7 @@ export const PromptInput: Component = () => {
|
|||||||
value={text()}
|
value={text()}
|
||||||
onInput={handleInput}
|
onInput={handleInput}
|
||||||
onKeyDown={handleKeyDown}
|
onKeyDown={handleKeyDown}
|
||||||
onPaste={imageAttach.handlePaste}
|
onPaste={handlePaste}
|
||||||
onScroll={syncHighlightScroll}
|
onScroll={syncHighlightScroll}
|
||||||
disabled={isDisabled()}
|
disabled={isDisabled()}
|
||||||
rows={1}
|
rows={1}
|
||||||
|
|||||||
Reference in New Issue
Block a user