Skip to content

Commit 2c395ba

Browse files
committed
Fix bugs
1 parent 44a6aef commit 2c395ba

2 files changed

Lines changed: 22 additions & 1 deletion

File tree

src/subcommands/chat/react/inputReducer.test.ts

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1501,6 +1501,23 @@ describe("chatInputStateReducers", () => {
15011501
expect(result.cursorOnSegmentIndex).toBe(0);
15021502
expect(result.cursorInSegmentOffset).toBe((firstSegmentText + secondSegmentText).length);
15031503
});
1504+
1505+
it("jumps to end of largePaste in one move when cursor is mid-word before largePaste", () => {
1506+
const initialState = createChatUserInputState(
1507+
[
1508+
{ type: "text", content: "ddf" },
1509+
{ type: "largePaste", content: "x".repeat(1495) },
1510+
{ type: "text", content: "Helh" },
1511+
],
1512+
0,
1513+
"dd".length,
1514+
);
1515+
1516+
const result = moveCursorWordRight(initialState);
1517+
1518+
expect(result.cursorOnSegmentIndex).toBe(1);
1519+
expect(result.cursorInSegmentOffset).toBe(0);
1520+
});
15041521
});
15051522

15061523
describe("moveCursorToLineStart", () => {

src/subcommands/chat/react/inputReducer.ts

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -833,7 +833,11 @@ export function moveCursorWordRight(state: ChatUserInputState): ChatUserInputSta
833833
// Find next word boundary within current segment and move cursor there
834834
const newCursorOffset = findNextWordBoundaryInSegment(segmentContent, cursorOffset);
835835
draft.cursorInSegmentOffset = newCursorOffset;
836-
return;
836+
// If we reached the end of the segment, continue to jump to next segment
837+
if (newCursorOffset < segmentLength) {
838+
return;
839+
}
840+
// Fall through to jump to next segment
837841
}
838842
}
839843

0 commit comments

Comments
 (0)