@@ -12,7 +12,7 @@ import { Position } from 'vs/editor/common/core/position';
1212import { Range } from 'vs/editor/common/core/range' ;
1313import { Selection , SelectionDirection , ISelection } from 'vs/editor/common/core/selection' ;
1414import * 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' ;
1616import { DeleteOperations } from 'vs/editor/common/controller/cursorDeleteOperations' ;
1717import { TypeOperations } from 'vs/editor/common/controller/cursorTypeOperations' ;
1818import { TextModelEventType , ModelRawContentChangedEvent , RawContentChangedType } from 'vs/editor/common/model/textModelEvents' ;
@@ -98,6 +98,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
9898 private _isHandling : boolean ;
9999 private _isDoingComposition : boolean ;
100100 private _columnSelectData : IColumnSelectData ;
101+ private _prevEditOperationType : EditOperationType ;
101102
102103 constructor ( configuration : editorCommon . IConfiguration , model : editorCommon . IModel , viewModel : IViewModel ) {
103104 super ( ) ;
@@ -110,6 +111,7 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
110111 this . _isHandling = false ;
111112 this . _isDoingComposition = false ;
112113 this . _columnSelectData = null ;
114+ this . _prevEditOperationType = EditOperationType . Other ;
113115
114116 this . _register ( this . _model . addBulkListener ( ( events ) => {
115117 if ( this . _isHandling ) {
@@ -278,6 +280,9 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
278280 }
279281
280282 private _onModelContentChanged ( hadFlushEvent : boolean ) : void {
283+
284+ this . _prevEditOperationType = EditOperationType . Other ;
285+
281286 if ( hadFlushEvent ) {
282287 // a model.setValue() was called
283288 this . _cursors . dispose ( ) ;
@@ -322,6 +327,14 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
322327 this . setStates ( source , CursorChangeReason . NotSet , CursorState . fromModelSelections ( selections ) ) ;
323328 }
324329
330+ public getPrevEditOperationType ( ) : EditOperationType {
331+ return this . _prevEditOperationType ;
332+ }
333+
334+ public setPrevEditOperationType ( type : EditOperationType ) : void {
335+ this . _prevEditOperationType = type ;
336+ }
337+
325338 // ------ auxiliary handling logic
326339
327340 private _executeEditOperation ( opResult : EditOperationResult ) : void {
@@ -344,6 +357,8 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
344357 if ( result ) {
345358 // The commands were applied correctly
346359 this . _interpretCommandResult ( result ) ;
360+
361+ this . _prevEditOperationType = opResult . type ;
347362 }
348363
349364 if ( opResult . shouldPushStackElementAfter ) {
@@ -515,16 +530,16 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
515530 }
516531
517532 // 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 ) ) ;
519534 }
520535
521536 } 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 ) ) ;
523538 }
524539 }
525540
526541 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 ) ) ;
528543 }
529544
530545 private _paste ( text : string , pasteOnNewLine : boolean ) : void {
@@ -538,14 +553,14 @@ export class Cursor extends viewEvents.ViewEventEmitter implements ICursors {
538553 private _externalExecuteCommand ( command : editorCommon . ICommand ) : void {
539554 this . _cursors . killSecondaryCursors ( ) ;
540555
541- this . _executeEditOperation ( new EditOperationResult ( [ command ] , {
556+ this . _executeEditOperation ( new EditOperationResult ( EditOperationType . Other , [ command ] , {
542557 shouldPushStackElementBefore : false ,
543558 shouldPushStackElementAfter : false
544559 } ) ) ;
545560 }
546561
547562 private _externalExecuteCommands ( commands : editorCommon . ICommand [ ] ) : void {
548- this . _executeEditOperation ( new EditOperationResult ( commands , {
563+ this . _executeEditOperation ( new EditOperationResult ( EditOperationType . Other , commands , {
549564 shouldPushStackElementBefore : false ,
550565 shouldPushStackElementAfter : false
551566 } ) ) ;
0 commit comments