@@ -1966,6 +1966,47 @@ describe("chatInputStateReducers", () => {
19661966 expect ( result . cursorOnSegmentIndex ) . toBe ( 0 ) ;
19671967 expect ( result . cursorInSegmentOffset ) . toBe ( 0 ) ;
19681968 } ) ;
1969+
1970+ it ( "preserves text after cursor when line starts with largePaste" , ( ) => {
1971+ const initialState : ChatUserInputState = {
1972+ segments : [
1973+ { type : "largePaste" , content : "x" . repeat ( 100 ) } ,
1974+ { type : "text" , content : "should deleteshould keep" } ,
1975+ ] ,
1976+ cursorOnSegmentIndex : 1 ,
1977+ cursorInSegmentOffset : 13 ,
1978+ } ;
1979+
1980+ const result = deleteToLineStart ( initialState ) ;
1981+
1982+ expect ( result . segments . length ) . toBe ( 1 ) ;
1983+ expect ( result . segments [ 0 ] . type ) . toBe ( "text" ) ;
1984+ expect ( result . segments [ 0 ] . content ) . toBe ( "should keep" ) ;
1985+ expect ( result . cursorOnSegmentIndex ) . toBe ( 0 ) ;
1986+ expect ( result . cursorInSegmentOffset ) . toBe ( 0 ) ;
1987+ } ) ;
1988+
1989+ it ( "deletes largePaste when cursor is at paste start with text on both sides" , ( ) => {
1990+ const initialState : ChatUserInputState = {
1991+ segments : [
1992+ { type : "text" , content : "before" } ,
1993+ { type : "largePaste" , content : "x" . repeat ( 100 ) } ,
1994+ { type : "text" , content : "after" } ,
1995+ ] ,
1996+ cursorOnSegmentIndex : 1 ,
1997+ cursorInSegmentOffset : 0 ,
1998+ } ;
1999+
2000+ const result = deleteToLineStart ( initialState ) ;
2001+
2002+ expect ( result . segments . length ) . toBe ( 2 ) ;
2003+ expect ( result . segments [ 0 ] . type ) . toBe ( "largePaste" ) ;
2004+ expect ( result . segments [ 0 ] . content ) . toBe ( "x" . repeat ( 100 ) ) ;
2005+ expect ( result . segments [ 1 ] . type ) . toBe ( "text" ) ;
2006+ expect ( result . segments [ 1 ] . content ) . toBe ( "after" ) ;
2007+ expect ( result . cursorOnSegmentIndex ) . toBe ( 0 ) ;
2008+ expect ( result . cursorInSegmentOffset ) . toBe ( 0 ) ;
2009+ } ) ;
19692010 } ) ;
19702011
19712012 describe ( "deleteToLineEnd" , ( ) => {
@@ -2068,7 +2109,25 @@ describe("chatInputStateReducers", () => {
20682109 expect ( result . cursorOnSegmentIndex ) . toBe ( 0 ) ;
20692110 expect ( result . cursorInSegmentOffset ) . toBe ( 9 ) ;
20702111 } ) ;
2112+ it ( "deletes trailing largePaste when cursor is in text before it" , ( ) => {
2113+ const initialState : ChatUserInputState = {
2114+ segments : [
2115+ { type : "text" , content : "keep this" } ,
2116+ { type : "largePaste" , content : "x" . repeat ( 100 ) } ,
2117+ { type : "text" , content : "" } ,
2118+ ] ,
2119+ cursorOnSegmentIndex : 0 ,
2120+ cursorInSegmentOffset : 9 ,
2121+ } ;
2122+
2123+ const result = deleteToLineEnd ( initialState ) ;
20712124
2125+ expect ( result . segments . length ) . toBe ( 1 ) ;
2126+ expect ( result . segments [ 0 ] . type ) . toBe ( "text" ) ;
2127+ expect ( result . segments [ 0 ] . content ) . toBe ( "keep this" ) ;
2128+ expect ( result . cursorOnSegmentIndex ) . toBe ( 0 ) ;
2129+ expect ( result . cursorInSegmentOffset ) . toBe ( 9 ) ;
2130+ } ) ;
20722131 it ( "deletes to newline and preserves text after newline" , ( ) => {
20732132 const initialState : ChatUserInputState = {
20742133 segments : [ { type : "text" , content : "line one\nline two" } ] ,
0 commit comments