reformat the code

This commit is contained in:
Vlad Zinculescu 2012-10-22 18:42:05 +02:00 • committed by nightwing
commit 9c3e6c5cce

View file

@ -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) * 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 row = this.selection.getCursor().row;
var column = this.selection.getCursor().column; var column = this.selection.getCursor().column;
@ -1354,11 +1354,11 @@ var Editor = function(renderer, session) {
var c = this.session.getTextRange(charRange); var c = this.session.getTextRange(charRange);
//if the char is a digit //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 //get the whole number the digit is part of
var nr = this.getNumberAt(row, column); var nr = this.getNumberAt(row, column);
//if number found //if number found
if( nr ) { if(nr) {
var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end; var fp = nr.value.indexOf(".") >= 0 ? nr.start + nr.value.indexOf(".") + 1 : nr.end;
var decimals = nr.start + nr.value.length - fp; var decimals = nr.start + nr.value.length - fp;
@ -1366,7 +1366,7 @@ var Editor = function(renderer, session) {
t *= Math.pow(10, decimals); 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); amount *= Math.pow(10, nr.end - column - 1);
} else { } else {
amount *= Math.pow(10, nr.end - column); amount *= Math.pow(10, nr.end - column);
@ -1382,16 +1382,10 @@ var Editor = function(renderer, session) {
replaceRange.end.row = row; replaceRange.end.row = row;
replaceRange.start.column = nr.start; replaceRange.start.column = nr.start;
replaceRange.end.column = nr.end; 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 //reposition the cursor
this.moveCursorTo(row, cursor ); this.moveCursorTo(row, Math.max(nr.start +1, column + nnr.length - nr.value.length));
} }
} }