Fixed single replace and removed several spurious
log messages.
This commit is contained in:
parent
04b4a59a81
commit
5d9f8cf0e9
1 changed files with 11 additions and 18 deletions
|
|
@ -414,7 +414,6 @@ var Editor = function(renderer, doc) {
|
||||||
var size = _self.doc.getTabSize(),
|
var size = _self.doc.getTabSize(),
|
||||||
minIndent = Number.MAX_VALUE;
|
minIndent = Number.MAX_VALUE;
|
||||||
|
|
||||||
console.log("line indent " + lineIndent.length);
|
|
||||||
for (var row = cursor.row + 1; row <= end.row; ++row) {
|
for (var row = cursor.row + 1; row <= end.row; ++row) {
|
||||||
var indent = 0;
|
var indent = 0;
|
||||||
|
|
||||||
|
|
@ -426,11 +425,9 @@ var Editor = function(renderer, doc) {
|
||||||
indent += 1;
|
indent += 1;
|
||||||
else
|
else
|
||||||
break;
|
break;
|
||||||
console.log("Indent " + indent + "(" + line.length + ")");
|
|
||||||
if (/[^\s]$/.test(line))
|
if (/[^\s]$/.test(line))
|
||||||
minIndent = Math.min(indent, minIndent);
|
minIndent = Math.min(indent, minIndent);
|
||||||
}
|
}
|
||||||
console.log("min indent " + minIndent);
|
|
||||||
for (var row = cursor.row + 1; row <= end.row; ++row) {
|
for (var row = cursor.row + 1; row <= end.row; ++row) {
|
||||||
var outdent = minIndent;
|
var outdent = minIndent;
|
||||||
|
|
||||||
|
|
@ -440,8 +437,6 @@ var Editor = function(renderer, doc) {
|
||||||
outdent -= size;
|
outdent -= size;
|
||||||
else if (line.charAt(i) == ' ')
|
else if (line.charAt(i) == ' ')
|
||||||
outdent -= 1;
|
outdent -= 1;
|
||||||
console.log("from '" + line);
|
|
||||||
console.log("to '" + line.substr(i));
|
|
||||||
_self.doc.replace(new Range(row, 0, row, line.length), line.substr(i));
|
_self.doc.replace(new Range(row, 0, row, line.length), line.substr(i));
|
||||||
}
|
}
|
||||||
end.column += _self.doc.indentRows(
|
end.column += _self.doc.indentRows(
|
||||||
|
|
@ -766,8 +761,6 @@ var Editor = function(renderer, doc) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.gotoPageDown = function() {
|
this.gotoPageDown = function() {
|
||||||
console.log("Goto page down");
|
|
||||||
|
|
||||||
var row = this.getPageDownRow(),
|
var row = this.getPageDownRow(),
|
||||||
column = Math.min(this.getCursorPosition().column,
|
column = Math.min(this.getCursorPosition().column,
|
||||||
this.doc.getLine(row).length);
|
this.doc.getLine(row).length);
|
||||||
|
|
@ -777,8 +770,6 @@ var Editor = function(renderer, doc) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.gotoPageUp = function() {
|
this.gotoPageUp = function() {
|
||||||
console.log("Goto page up");
|
|
||||||
|
|
||||||
var row = this.getPageUpRow(),
|
var row = this.getPageUpRow(),
|
||||||
column = Math.min(this.getCursorPosition().column,
|
column = Math.min(this.getCursorPosition().column,
|
||||||
this.doc.getLine(row).length);
|
this.doc.getLine(row).length);
|
||||||
|
|
@ -922,20 +913,21 @@ var Editor = function(renderer, doc) {
|
||||||
};
|
};
|
||||||
|
|
||||||
this.replace = function(replacement, options) {
|
this.replace = function(replacement, options) {
|
||||||
if (options)
|
console.log("replacing with " + replacement);
|
||||||
this.$search.set(options);
|
if (options)
|
||||||
var range = this.$tryReplace(this.getSelectionRange(), replacement);
|
this.$search.set(options);
|
||||||
if (range !== null)
|
|
||||||
this.selection.setSelectionRange(range);
|
var range = this.$search.find(this.doc);
|
||||||
this.$updateDesiredColumn();
|
this.$tryReplace(range, replacement);
|
||||||
|
if (range !== null)
|
||||||
|
this.selection.setSelectionRange(range);
|
||||||
|
this.$updateDesiredColumn();
|
||||||
},
|
},
|
||||||
|
|
||||||
this.replaceAll = function(replacement, options) {
|
this.replaceAll = function(replacement, options) {
|
||||||
if (options) {
|
if (options) {
|
||||||
console.log("Find " + options.needle);
|
|
||||||
this.$search.set(options);
|
this.$search.set(options);
|
||||||
}
|
}
|
||||||
console.log("Replace " + replacement);
|
|
||||||
this.clearSelection();
|
this.clearSelection();
|
||||||
this.selection.moveCursorTo(0, 0);
|
this.selection.moveCursorTo(0, 0);
|
||||||
|
|
||||||
|
|
@ -945,7 +937,8 @@ var Editor = function(renderer, doc) {
|
||||||
|
|
||||||
for (var i = ranges.length - 1; i >= 0; --i)
|
for (var i = ranges.length - 1; i >= 0; --i)
|
||||||
this.$tryReplace(ranges[i], replacement);
|
this.$tryReplace(ranges[i], replacement);
|
||||||
this.selection.setSelectionRange(ranges[0]);
|
if (ranges[0] !== null)
|
||||||
|
this.selection.setSelectionRange(ranges[0]);
|
||||||
this.$updateDesiredColumn();
|
this.$updateDesiredColumn();
|
||||||
},
|
},
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue