summaryrefslogtreecommitdiff
path: root/packages/cli/src/ui/components/shared/text-buffer.test.ts
diff options
context:
space:
mode:
authorJacob Richman <[email protected]>2025-06-16 22:21:22 +0000
committerGitHub <[email protected]>2025-06-16 15:21:22 -0700
commita7e45d47cda0b2b4f6325e8700434e7b2a2660ed (patch)
treeb9f45d24835f0eebcaa0ea855f68e9223a84f384 /packages/cli/src/ui/components/shared/text-buffer.test.ts
parent11f524c1251e1f604c9b64a215b81512e23cd396 (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.test.ts')
-rw-r--r--packages/cli/src/ui/components/shared/text-buffer.test.ts15
1 files changed, 15 insertions, 0 deletions
diff --git a/packages/cli/src/ui/components/shared/text-buffer.test.ts b/packages/cli/src/ui/components/shared/text-buffer.test.ts
index c5295fc1..218ed1c3 100644
--- a/packages/cli/src/ui/components/shared/text-buffer.test.ts
+++ b/packages/cli/src/ui/components/shared/text-buffer.test.ts
@@ -173,6 +173,21 @@ describe('useTextBuffer', () => {
expect(state.visualCursor).toEqual([0, 2]);
});
+ it('insert: should insert text in the middle of a line', () => {
+ const { result } = renderHook(() =>
+ useTextBuffer({
+ initialText: 'abc',
+ viewport,
+ isValidPath: () => false,
+ }),
+ );
+ act(() => result.current.move('right'));
+ act(() => result.current.insert('-NEW-'));
+ const state = getBufferState(result);
+ expect(state.text).toBe('a-NEW-bc');
+ expect(state.cursor).toEqual([0, 6]);
+ });
+
it('newline: should create a new line and move cursor', () => {
const { result } = renderHook(() =>
useTextBuffer({