Skip to content

Commit

Permalink
bug: bad cursor placement after pressing enter
Browse files Browse the repository at this point in the history
  • Loading branch information
nvms committed Dec 9, 2023
1 parent 0a8541b commit bb26eb5
Showing 1 changed file with 5 additions and 1 deletion.
6 changes: 5 additions & 1 deletion webview/src/components/GrowingTextarea.svelte
Original file line number Diff line number Diff line change
Expand Up @@ -32,7 +32,11 @@
dispatch("submit", value);
} else if (!event.shiftKey && enterCreatesNewLine) {
event.preventDefault();
value += "\n";
const selectionStart = event.target.selectionStart;
const selectionEnd = event.target.selectionEnd;
value = value.slice(0, selectionStart) + "\n" + value.slice(selectionEnd);
event.target.value = value; // Set the textarea value to the updated value
event.target.selectionStart = event.target.selectionEnd = selectionStart + 1;
tick().then(() => {
autoGrow();
});
Expand Down

0 comments on commit bb26eb5

Please sign in to comment.