@@ -11,6 +11,8 @@ import { Selection } from 'vs/editor/common/core/selection';
1111import { deserializePipePositions , serializePipePositions , testRepeatedActionAndExtractPositions } from 'vs/editor/contrib/wordOperations/test/wordTestUtils' ;
1212import { CursorWordEndLeft , CursorWordEndLeftSelect , CursorWordEndRight , CursorWordEndRightSelect , CursorWordLeft , CursorWordLeftSelect , CursorWordRight , CursorWordRightSelect , CursorWordStartLeft , CursorWordStartLeftSelect , CursorWordStartRight , CursorWordStartRightSelect , DeleteWordEndLeft , DeleteWordEndRight , DeleteWordLeft , DeleteWordRight , DeleteWordStartLeft , DeleteWordStartRight , CursorWordAccessibilityLeft , CursorWordAccessibilityLeftSelect , CursorWordAccessibilityRight , CursorWordAccessibilityRightSelect } from 'vs/editor/contrib/wordOperations/wordOperations' ;
1313import { withTestCodeEditor } from 'vs/editor/test/browser/testCodeEditor' ;
14+ import { Handler } from 'vs/editor/common/editorCommon' ;
15+ import { Cursor } from 'vs/editor/common/controller/cursor' ;
1416
1517suite ( 'WordOperations' , ( ) => {
1618
@@ -193,6 +195,32 @@ suite('WordOperations', () => {
193195 assert . deepEqual ( actual , EXPECTED ) ;
194196 } ) ;
195197
198+ test ( 'issue #51275 - cursorWordStartLeft does not push undo/redo stack element' , ( ) => {
199+ function cursorCommand ( cursor : Cursor , command : string , extraData ?: any , overwriteSource ?: string ) {
200+ cursor . trigger ( overwriteSource || 'tests' , command , extraData ) ;
201+ }
202+
203+ function type ( cursor : Cursor , text : string ) {
204+ for ( let i = 0 ; i < text . length ; i ++ ) {
205+ cursorCommand ( cursor , Handler . Type , { text : text . charAt ( i ) } , 'keyboard' ) ;
206+ }
207+ }
208+
209+ withTestCodeEditor ( '' , { } , ( editor , cursor ) => {
210+ type ( cursor , 'foo bar baz' ) ;
211+ assert . equal ( editor . getValue ( ) , 'foo bar baz' ) ;
212+
213+ cursorWordStartLeft ( editor ) ;
214+ cursorWordStartLeft ( editor ) ;
215+ type ( cursor , 'q' ) ;
216+
217+ assert . equal ( editor . getValue ( ) , 'foo qbar baz' ) ;
218+
219+ cursorCommand ( cursor , Handler . Undo , { } ) ;
220+ assert . equal ( editor . getValue ( ) , 'foo bar baz' ) ;
221+ } ) ;
222+ } ) ;
223+
196224 test ( 'cursorWordEndLeft' , ( ) => {
197225 const EXPECTED = [ '| /*| Just| some| more| text| a|+=| 3| +|5|-|3| +| 7| */| ' ] . join ( '\n' ) ;
198226 const [ text , ] = deserializePipePositions ( EXPECTED ) ;
0 commit comments