fix(tui): preserve streamed code on completion

This commit is contained in:
Xubin Ren committed 2026-09-05 00:32:27 +08:00
1 parent 5ec4b16863
commit cb13a15780
4 files changed
+78 -14

No files matched your search

+17 -3
View File
@@ -1738,16 +1738,30 @@ export class NanobotTui {
key.preventDefault()
return
}
if (!key.ctrl && !key.meta && !key.shift && (key.name === "left" || key.name === "right")) {
if (!key.ctrl && !key.meta && (key.name === "left" || key.name === "right")) {
const direction = key.name === "left" ? -1 : 1
const cursor = this.composerStringCursor()
const target = this.draft.moveImageCursor(
this.composer.plainText,
this.composerStringCursor(),
cursor,
direction,
)
if (target !== null) {
this.composerCursor = target
this.setComposerStringCursor(this.composer.plainText, target)
if (key.shift) {
const cursorOffset = this.composerOffsetForStringIndex(this.composer.plainText, cursor)
const targetOffset = this.composerOffsetForStringIndex(this.composer.plainText, target)
this.composer.setSelection(
Math.min(cursorOffset, targetOffset),
Math.max(cursorOffset, targetOffset),
)
// OpenTUI 0.5.10 clears the selection through the public cursor
// setter. Move the native edit cursor directly so the placeholder
// remains one selected, replaceable unit.
this.composer.editBuffer.setCursorByOffset(targetOffset)
} else {
this.setComposerStringCursor(this.composer.plainText, target)
}
key.preventDefault()
return
}