@@ -140,10 +140,10 @@ define(function(require, exports, module) {
140
140
TextModeTokenRe . lastIndex = 0 ;
141
141
return TextModeTokenRe . test ( ch ) ;
142
142
} ;
143
-
143
+
144
144
( function ( ) {
145
145
oop . implement ( CodeMirror . prototype , EventEmitter ) ;
146
-
146
+
147
147
this . destroy = function ( ) {
148
148
this . ace . off ( 'change' , this . onChange ) ;
149
149
this . ace . off ( 'changeSelection' , this . onSelectionChange ) ;
@@ -263,7 +263,7 @@ define(function(require, exports, module) {
263
263
r . cursor = Range . comparePoints ( r . start , head ) ? r . end : r . start ;
264
264
return r ;
265
265
} ) ;
266
-
266
+
267
267
if ( this . ace . inVirtualSelectionMode ) {
268
268
this . ace . selection . fromOrientedRange ( ranges [ 0 ] ) ;
269
269
return ;
@@ -306,7 +306,7 @@ define(function(require, exports, module) {
306
306
var rowShift = ( end . row - start . row ) * ( isInsert ? 1 : - 1 ) ;
307
307
var colShift = ( end . column - start . column ) * ( isInsert ? 1 : - 1 ) ;
308
308
if ( isInsert ) end = start ;
309
-
309
+
310
310
for ( var i in this . marks ) {
311
311
var point = this . marks [ i ] ;
312
312
var cmp = Range . comparePoints ( point , start ) ;
@@ -473,7 +473,7 @@ define(function(require, exports, module) {
473
473
if ( ! e ) e = s ;
474
474
return this . ace . session . replace ( new Range ( s . line , s . ch , e . line , e . ch ) , text ) ;
475
475
} ;
476
- this . replaceSelection =
476
+ this . replaceSelection =
477
477
this . replaceSelections = function ( p ) {
478
478
var sel = this . ace . selection ;
479
479
if ( this . ace . inVirtualSelectionMode ) {
@@ -790,12 +790,12 @@ dom.importCssString(".normal-mode .ace_cursor{\
790
790
inp . value = newVal ;
791
791
} else {
792
792
if ( closed ) return ;
793
-
793
+
794
794
if ( newVal && newVal . type == "blur" ) {
795
795
if ( document . activeElement === inp )
796
796
return ;
797
797
}
798
-
798
+
799
799
me . state . dialog = null ;
800
800
closed = true ;
801
801
dialog . parentNode . removeChild ( dialog ) ;
@@ -869,7 +869,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
869
869
} ) ;
870
870
} ) ( ) ;
871
871
872
-
872
+
873
873
var defaultKeymap = [
874
874
// Key to key mapping. This goes first to make it possible to override
875
875
// existing mappings.
@@ -5883,10 +5883,16 @@ dom.importCssString(".normal-mode .ace_cursor{\
5883
5883
stop ( ) ;
5884
5884
} ) ;
5885
5885
}
5886
+ function lineBreakCount ( text ) {
5887
+ return ( text . match ( / [ \n \r ] / g) || [ ] ) . length ;
5888
+ }
5886
5889
function replace ( ) {
5887
5890
var text = cm . getRange ( searchCursor . from ( ) , searchCursor . to ( ) ) ;
5888
5891
var newText = text . replace ( query , replaceWith ) ;
5889
5892
searchCursor . replace ( newText ) ;
5893
+ var lineBreakDifference = lineBreakCount ( newText ) - lineBreakCount ( text ) ;
5894
+ lineEnd += lineBreakDifference
5895
+ lastPos . line += lineBreakDifference
5890
5896
}
5891
5897
function next ( ) {
5892
5898
// The below only loops to skip over multiple occurrences on the same
@@ -6378,7 +6384,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
6378
6384
} else if ( wasMultiselect && vim . visualBlock ) {
6379
6385
vim . wasInVisualBlock = true ;
6380
6386
}
6381
-
6387
+
6382
6388
if ( key == '<Esc>' && ! vim . insertMode && ! vim . visualMode && wasMultiselect ) {
6383
6389
cm . ace . exitMultiSelectMode ( ) ;
6384
6390
} else if ( visualBlock || ! wasMultiselect || cm . ace . inVirtualSelectionMode ) {
@@ -6397,7 +6403,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
6397
6403
anchor = offsetCursor ( anchor , 0 , anchorOffset ) ;
6398
6404
cm . state . vim . sel . head = head ;
6399
6405
cm . state . vim . sel . anchor = anchor ;
6400
-
6406
+
6401
6407
isHandled = handleKey ( cm , key , origin ) ;
6402
6408
sel . $desiredColumn = cm . state . vim . lastHPos == - 1 ? null : cm . state . vim . lastHPos ;
6403
6409
if ( cm . virtualSelectionMode ( ) ) {
@@ -6425,12 +6431,12 @@ dom.importCssString(".normal-mode .ace_cursor{\
6425
6431
var top = pixelPos . top ;
6426
6432
var left = pixelPos . left ;
6427
6433
if ( ! vim . insertMode ) {
6428
- var isbackwards = ! sel . cursor
6434
+ var isbackwards = ! sel . cursor
6429
6435
? session . selection . isBackwards ( ) || session . selection . isEmpty ( )
6430
6436
: Range . comparePoints ( sel . cursor , sel . start ) <= 0 ;
6431
6437
if ( ! isbackwards && left > w )
6432
6438
left -= w ;
6433
- }
6439
+ }
6434
6440
if ( ! vim . insertMode && vim . status ) {
6435
6441
h = h / 2 ;
6436
6442
top += h ;
@@ -6444,7 +6450,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
6444
6450
var cm = editor . state . cm ;
6445
6451
var vim = getVim ( cm ) ;
6446
6452
if ( keyCode == - 1 ) return ;
6447
-
6453
+
6448
6454
// in non-insert mode we try to find the ascii key corresponding to the text in textarea
6449
6455
// this is needed because in languages that use latin alphabet we want to get the key that browser sends to the textarea
6450
6456
// and in non
@@ -6475,7 +6481,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
6475
6481
data . inputChar = data . inputKey = null ;
6476
6482
}
6477
6483
}
6478
-
6484
+
6479
6485
// ctrl-c is special it both exits mode and copies text
6480
6486
if ( key == "c" && hashId == 1 ) { // key == "ctrl-c"
6481
6487
if ( ! useragent . isMac && editor . getCopyText ( ) ) {
@@ -6485,13 +6491,13 @@ dom.importCssString(".normal-mode .ace_cursor{\
6485
6491
return { command : "null" , passEvent : true } ;
6486
6492
}
6487
6493
}
6488
-
6494
+
6489
6495
if ( key == "esc" && ! vim . insertMode && ! vim . visualMode && ! cm . ace . inMultiSelectMode ) {
6490
6496
var searchState = getSearchState ( cm ) ;
6491
6497
var overlay = searchState . getOverlay ( ) ;
6492
6498
if ( overlay ) cm . removeOverlay ( overlay ) ;
6493
6499
}
6494
-
6500
+
6495
6501
if ( hashId == - 1 || hashId & 1 || hashId === 0 && key . length > 1 ) {
6496
6502
var insertMode = vim . insertMode ;
6497
6503
var name = lookupKey ( hashId , key , e || { } ) ;
@@ -6590,7 +6596,7 @@ dom.importCssString(".normal-mode .ace_cursor{\
6590
6596
{ keys : 'zA' , type : 'action' , action : 'fold' , actionArgs : { toggle : true , all : true } } ,
6591
6597
{ keys : 'zf' , type : 'action' , action : 'fold' , actionArgs : { open : true , all : true } } ,
6592
6598
{ keys : 'zd' , type : 'action' , action : 'fold' , actionArgs : { open : true , all : true } } ,
6593
-
6599
+
6594
6600
{ keys : '<C-A-k>' , type : 'action' , action : 'aceCommand' , actionArgs : { name : "addCursorAbove" } } ,
6595
6601
{ keys : '<C-A-j>' , type : 'action' , action : 'aceCommand' , actionArgs : { name : "addCursorBelow" } } ,
6596
6602
{ keys : '<C-A-S-k>' , type : 'action' , action : 'aceCommand' , actionArgs : { name : "addCursorAboveSkipCurrent" } } ,
0 commit comments