AI edit: support CURSOR insert at caret position

This commit is contained in:
2026-05-27 11:10:11 +02:00
parent da1194e8a5
commit 0e028c6b97
2 changed files with 10 additions and 5 deletions
+5
View File
@@ -1055,6 +1055,11 @@ async function sendAiChat() {
content.value = content.value.trimEnd() + '\n\n' + editContent
} else if (hint === 'PREPEND') {
content.value = editContent + '\n\n' + content.value
} else if (hint === 'CURSOR' || hint === 'INSERT') {
// Insert at cursor position
const ta = editor.value
const pos = ta ? ta.selectionStart : content.value.length
content.value = content.value.substring(0, pos) + editContent + content.value.substring(pos)
} else {
// REPLACE or unknown — replace entire document
content.value = hint === 'REPLACE' ? editContent : fullText