@@ -87,18 +87,30 @@ export function activateMirrorCursor(
8787 }
8888 }
8989
90+ const exitMirrorMode = ( ) => {
91+ inMirrorMode = false ;
92+ window . activeTextEditor ! . selections = [ window . activeTextEditor ! . selections [ 0 ] ] ;
93+ } ;
94+
9095 if ( cursors . length === 2 && inMirrorMode ) {
91- // Check two cases
9296 if ( event . selections [ 0 ] . isEmpty && event . selections [ 1 ] . isEmpty ) {
97+ if (
98+ prevCursors . length === 2 &&
99+ event . selections [ 0 ] . anchor . line !== prevCursors [ 0 ] . anchor . line &&
100+ event . selections [ 1 ] . anchor . line !== prevCursors [ 0 ] . anchor . line
101+ ) {
102+ exitMirrorMode ( ) ;
103+ return ;
104+ }
105+
93106 const charBeforeAndAfterPositionsRoughtlyEqual = isCharBeforeAndAfterPositionsRoughtlyEqual (
94107 event . textEditor . document ,
95108 event . selections [ 0 ] . anchor ,
96109 event . selections [ 1 ] . anchor
97110 ) ;
98111
99112 if ( ! charBeforeAndAfterPositionsRoughtlyEqual ) {
100- inMirrorMode = false ;
101- window . activeTextEditor ! . selections = [ window . activeTextEditor ! . selections [ 0 ] ] ;
113+ exitMirrorMode ( ) ;
102114 return ;
103115 } else {
104116 // Need to cleanup in the case of <div |></div |>
@@ -109,11 +121,10 @@ export function activateMirrorCursor(
109121 event . selections [ 1 ] . anchor
110122 )
111123 ) {
112- inMirrorMode = false ;
113124 const cleanupEdit = new WorkspaceEdit ( ) ;
114125 const cleanupRange = new Range ( event . selections [ 1 ] . anchor . translate ( 0 , - 1 ) , event . selections [ 1 ] . anchor ) ;
115126 cleanupEdit . replace ( event . textEditor . document . uri , cleanupRange , '' ) ;
116- window . activeTextEditor ! . selections = [ window . activeTextEditor ! . selections [ 0 ] ] ;
127+ exitMirrorMode ( ) ;
117128 workspace . applyEdit ( cleanupEdit ) ;
118129 }
119130 }
0 commit comments