diff options
| author | Jacob Richman <[email protected]> | 2025-06-16 22:21:22 +0000 |
|---|---|---|
| committer | GitHub <[email protected]> | 2025-06-16 15:21:22 -0700 |
| commit | a7e45d47cda0b2b4f6325e8700434e7b2a2660ed (patch) | |
| tree | b9f45d24835f0eebcaa0ea855f68e9223a84f384 /packages/cli/src/ui/components/shared/text-buffer.ts | |
| parent | 11f524c1251e1f604c9b64a215b81512e23cd396 (diff) | |
Fix bug where single line inserts were deleting all text after the in… (#1114)
Diffstat (limited to 'packages/cli/src/ui/components/shared/text-buffer.ts')
| -rw-r--r-- | packages/cli/src/ui/components/shared/text-buffer.ts | 4 |
1 files changed, 3 insertions, 1 deletions
diff --git a/packages/cli/src/ui/components/shared/text-buffer.ts b/packages/cli/src/ui/components/shared/text-buffer.ts index ef21d00a..6b025dd5 100644 --- a/packages/cli/src/ui/components/shared/text-buffer.ts +++ b/packages/cli/src/ui/components/shared/text-buffer.ts @@ -635,9 +635,9 @@ export function useTextBuffer({ const lineContent = currentLine(newCursorRow); const before = cpSlice(lineContent, 0, newCursorCol); const after = cpSlice(lineContent, newCursorCol); - newLines[newCursorRow] = before + parts[0]; if (parts.length > 1) { + newLines[newCursorRow] = before + parts[0]; const remainingParts = parts.slice(1); const lastPartOriginal = remainingParts.pop() ?? ''; newLines.splice(newCursorRow + 1, 0, ...remainingParts); @@ -649,6 +649,8 @@ export function useTextBuffer({ newCursorRow = newCursorRow + parts.length - 1; newCursorCol = cpLen(lastPartOriginal); } else { + newLines[newCursorRow] = before + parts[0] + after; + newCursorCol = cpLen(before) + cpLen(parts[0]); } } else if (op.type === 'backspace') { |
