From a7e45d47cda0b2b4f6325e8700434e7b2a2660ed Mon Sep 17 00:00:00 2001 From: Jacob Richman Date: Mon, 16 Jun 2025 22:21:22 +0000 Subject: Fix bug where single line inserts were deleting all text after the in… (#1114) MIME-Version: 1.0 Content-Type: text/plain; charset=UTF-8 Content-Transfer-Encoding: 8bit --- packages/cli/src/ui/components/shared/text-buffer.test.ts | 15 +++++++++++++++ 1 file changed, 15 insertions(+) (limited to 'packages/cli/src/ui/components/shared/text-buffer.test.ts') 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({ -- cgit v1.2.3