@@ -12,7 +12,7 @@ import { Position } from 'vs/editor/common/core/position';
12
12
import { Range } from 'vs/editor/common/core/range' ;
13
13
import { Selection , SelectionDirection , ISelection } from 'vs/editor/common/core/selection' ;
14
14
import * as editorCommon from 'vs/editor/common/editorCommon' ;
15
- import { CursorColumns , CursorConfiguration , EditOperationResult , CursorContext , CursorState , RevealTarget , IColumnSelectData , ICursors } from 'vs/editor/common/controller/cursorCommon' ;
15
+ import { CursorColumns , CursorConfiguration , EditOperationResult , CursorContext , CursorState , RevealTarget , IColumnSelectData , ICursors , EditOperationType } from 'vs/editor/common/controller/cursorCommon' ;
16
16
import { DeleteOperations } from 'vs/editor/common/controller/cursorDeleteOperations' ;
17
17
import { TypeOperations } from 'vs/editor/common/controller/cursorTypeOperations' ;
18
18
import { TextModelEventType , ModelRawContentChangedEvent , RawContentChangedType } from 'vs/editor/common/model/textModelEvents' ;
@@ -98,6 +98,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
98
98
private _isHandling : boolean ;
99
99
private _isDoingComposition : boolean ;
100
100
private _columnSelectData : IColumnSelectData ;
101
+ private _prevEditOperationType : EditOperationType ;
101
102
102
103
constructor ( configuration : editorCommon . IConfiguration , model : editorCommon . IModel , viewModel : IViewModel ) {
103
104
super ( ) ;
@@ -110,6 +111,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
110
111
this . _isHandling = false ;
111
112
this . _isDoingComposition = false ;
112
113
this . _columnSelectData = null ;
114
+ this . _prevEditOperationType = EditOperationType . Other ;
113
115
114
116
this . _register ( this . _model . addBulkListener ( ( events ) => {
115
117
if ( this . _isHandling ) {
@@ -278,6 +280,9 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
278
280
}
279
281
280
282
private _onModelContentChanged ( hadFlushEvent : boolean ) : void {
283
+
284
+ this . _prevEditOperationType = EditOperationType . Other ;
285
+
281
286
if ( hadFlushEvent ) {
282
287
// a model.setValue() was called
283
288
this . _cursors . dispose ( ) ;
@@ -322,6 +327,14 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
322
327
this . setStates ( source , CursorChangeReason . NotSet , CursorState . fromModelSelections ( selections ) ) ;
323
328
}
324
329
330
+ public getPrevEditOperationType ( ) : EditOperationType {
331
+ return this . _prevEditOperationType ;
332
+ }
333
+
334
+ public setPrevEditOperationType ( type : EditOperationType ) : void {
335
+ this . _prevEditOperationType = type ;
336
+ }
337
+
325
338
// ------ auxiliary handling logic
326
339
327
340
private _executeEditOperation ( opResult : EditOperationResult ) : void {
@@ -344,6 +357,8 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
344
357
if ( result ) {
345
358
// The commands were applied correctly
346
359
this . _interpretCommandResult ( result ) ;
360
+
361
+ this . _prevEditOperationType = opResult . type ;
347
362
}
348
363
349
364
if ( opResult . shouldPushStackElementAfter ) {
@@ -515,16 +530,16 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
515
530
}
516
531
517
532
// Here we must interpret each typed character individually, that's why we create a new context
518
- this . _executeEditOperation ( TypeOperations . typeWithInterceptors ( this . context . config , this . context . model , this . getSelections ( ) , chr ) ) ;
533
+ this . _executeEditOperation ( TypeOperations . typeWithInterceptors ( this . _prevEditOperationType , this . context . config , this . context . model , this . getSelections ( ) , chr ) ) ;
519
534
}
520
535
521
536
} else {
522
- this . _executeEditOperation ( TypeOperations . typeWithoutInterceptors ( this . context . config , this . context . model , this . getSelections ( ) , text ) ) ;
537
+ this . _executeEditOperation ( TypeOperations . typeWithoutInterceptors ( this . _prevEditOperationType , this . context . config , this . context . model , this . getSelections ( ) , text ) ) ;
523
538
}
524
539
}
525
540
526
541
private _replacePreviousChar ( text : string , replaceCharCnt : number ) : void {
527
- this . _executeEditOperation ( TypeOperations . replacePreviousChar ( this . context . config , this . context . model , this . getSelections ( ) , text , replaceCharCnt ) ) ;
542
+ this . _executeEditOperation ( TypeOperations . replacePreviousChar ( this . _prevEditOperationType , this . context . config , this . context . model , this . getSelections ( ) , text , replaceCharCnt ) ) ;
528
543
}
529
544
530
545
private _paste ( text : string , pasteOnNewLine : boolean ) : void {
@@ -538,14 +553,14 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
538
553
private _externalExecuteCommand ( command : editorCommon . ICommand ) : void {
539
554
this . _cursors . killSecondaryCursors ( ) ;
540
555
541
- this . _executeEditOperation ( new EditOperationResult ( [ command ] , {
556
+ this . _executeEditOperation ( new EditOperationResult ( EditOperationType . Other , [ command ] , {
542
557
shouldPushStackElementBefore : false ,
543
558
shouldPushStackElementAfter : false
544
559
} ) ) ;
545
560
}
546
561
547
562
private _externalExecuteCommands ( commands : editorCommon . ICommand [ ] ) : void {
548
- this . _executeEditOperation ( new EditOperationResult ( commands , {
563
+ this . _executeEditOperation ( new EditOperationResult ( EditOperationType . Other , commands , {
549
564
shouldPushStackElementBefore : false ,
550
565
shouldPushStackElementAfter : false
551
566
} ) ) ;
0 commit comments