@@ -2007,6 +2007,25 @@ describe("chatInputStateReducers", () => {
20072007 expect ( result . cursorOnSegmentIndex ) . toBe ( 0 ) ;
20082008 expect ( result . cursorInSegmentOffset ) . toBe ( 0 ) ;
20092009 } ) ;
2010+
2011+ it ( "deletes largePaste when cursor is at trailing placeholder after paste" , ( ) => {
2012+ const initialState : ChatUserInputState = {
2013+ segments : [
2014+ { type : "largePaste" , content : "x" . repeat ( 100 ) } ,
2015+ { type : "text" , content : "" } ,
2016+ ] ,
2017+ cursorOnSegmentIndex : 1 ,
2018+ cursorInSegmentOffset : 0 ,
2019+ } ;
2020+
2021+ const result = deleteToLineStart ( initialState ) ;
2022+
2023+ expect ( result . segments . length ) . toBe ( 1 ) ;
2024+ expect ( result . segments [ 0 ] . type ) . toBe ( "text" ) ;
2025+ expect ( result . segments [ 0 ] . content ) . toBe ( "" ) ;
2026+ expect ( result . cursorOnSegmentIndex ) . toBe ( 0 ) ;
2027+ expect ( result . cursorInSegmentOffset ) . toBe ( 0 ) ;
2028+ } ) ;
20102029 } ) ;
20112030
20122031 describe ( "deleteToLineEnd" , ( ) => {
@@ -2142,5 +2161,24 @@ describe("chatInputStateReducers", () => {
21422161 expect ( result . cursorOnSegmentIndex ) . toBe ( 0 ) ;
21432162 expect ( result . cursorInSegmentOffset ) . toBe ( 5 ) ;
21442163 } ) ;
2164+
2165+ it ( "deletes largePaste and following text when cursor is at offset 0 of largePaste" , ( ) => {
2166+ const initialState : ChatUserInputState = {
2167+ segments : [
2168+ { type : "largePaste" , content : "x" . repeat ( 100 ) } ,
2169+ { type : "text" , content : "following text" } ,
2170+ ] ,
2171+ cursorOnSegmentIndex : 0 ,
2172+ cursorInSegmentOffset : 0 ,
2173+ } ;
2174+
2175+ const result = deleteToLineEnd ( initialState ) ;
2176+
2177+ expect ( result . segments . length ) . toBe ( 1 ) ;
2178+ expect ( result . segments [ 0 ] . type ) . toBe ( "text" ) ;
2179+ expect ( result . segments [ 0 ] . content ) . toBe ( "" ) ;
2180+ expect ( result . cursorOnSegmentIndex ) . toBe ( 0 ) ;
2181+ expect ( result . cursorInSegmentOffset ) . toBe ( 0 ) ;
2182+ } ) ;
21452183 } ) ;
21462184} ) ;
0 commit comments