reformat the code
This commit is contained in:
parent
e3ad71b4e1
commit
9c3e6c5cce
1 changed files with 6 additions and 12 deletions
|
|
@ -1341,7 +1341,7 @@ var Editor = function(renderer, session) {
|
|||
*
|
||||
* If the character before the cursor is a number, you can increase/descrease it's value with 1 by pressing Ctrl+Cmd+Up/Down (Mac) Ctrl+Shift+Up/Down (Win)
|
||||
**/
|
||||
this.modifyNumber = function( amount ) {
|
||||
this.modifyNumber = function(amount) {
|
||||
var row = this.selection.getCursor().row;
|
||||
var column = this.selection.getCursor().column;
|
||||
|
||||
|
|
@ -1354,11 +1354,11 @@ var Editor = function(renderer, session) {
|
|||
|
||||
var c = this.session.getTextRange(charRange);
|
||||
//if the char is a digit
|
||||
if( !isNaN(parseFloat(c)) && isFinite(c) ) {
|
||||
if(!isNaN(parseFloat(c)) && isFinite(c)) {
|
||||
//get the whole number the digit is part of
|
||||
var nr = this.getNumberAt(row, column);
|
||||
//if number found
|
||||
if( nr ) {
|
||||
if(nr) {
|
||||
var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end;
|
||||
var decimals = nr.start + nr.value.length - fp;
|
||||
|
||||
|
|
@ -1366,7 +1366,7 @@ var Editor = function(renderer, session) {
|
|||
t *= Math.pow(10, decimals);
|
||||
|
||||
|
||||
if( fp !== nr.end && column < fp){
|
||||
if(fp !== nr.end && column < fp){
|
||||
amount *= Math.pow(10, nr.end - column - 1);
|
||||
} else {
|
||||
amount *= Math.pow(10, nr.end - column);
|
||||
|
|
@ -1382,16 +1382,10 @@ var Editor = function(renderer, session) {
|
|||
replaceRange.end.row = row;
|
||||
replaceRange.start.column = nr.start;
|
||||
replaceRange.end.column = nr.end;
|
||||
this.session.replace(replaceRange, nnr );
|
||||
this.session.replace(replaceRange, nnr);
|
||||
|
||||
var cursor = column;
|
||||
var offset = nnr.length - nr.value.length;
|
||||
|
||||
|
||||
cursor = Math.max(nr.start +1, cursor + offset);
|
||||
console.log(offset, nr.value.length, nnr.length)
|
||||
//reposition the cursor
|
||||
this.moveCursorTo(row, cursor );
|
||||
this.moveCursorTo(row, Math.max(nr.start +1, column + nnr.length - nr.value.length));
|
||||
|
||||
}
|
||||
}
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue