Fixed a bug in single line tabbing that caused
the tab length not being taken into account. Added DOM emulation to the unit tests so that they can be run from node. Extended the Mockrenderer for the unit tests. Made the majority of the unit tests work again (barring those for moveLinesUp, see below). Fixed a bug in moveLinesUp that caused an empty line to be inserted. However, this fix causes the editor to break (need to look at this).
This commit is contained in:
parent
abb53c3faa
commit
215cfbf4bf
18 changed files with 555 additions and 474 deletions
|
|
@ -427,7 +427,7 @@ var Editor =function(renderer, doc) {
|
|||
var shouldOutdent = _self.mode.checkOutdent(lineState, _self.doc.getLine(cursor.row), text);
|
||||
var line = _self.doc.getLine(cursor.row),
|
||||
lineIndent = _self.mode.getNextLineIndent(lineState, line, _self.doc.getTabString());
|
||||
var end = _self.doc.insert(cursor, text);
|
||||
var end = _self.doc.insert(cursor, text);
|
||||
|
||||
/* TODO: This shortcut is somehow broken
|
||||
if (!shouldOutdent && line != _self.doc.getLine(row) && text != "\n") {
|
||||
|
|
@ -457,6 +457,7 @@ var Editor =function(renderer, doc) {
|
|||
if (/[^\s]$/.test(line))
|
||||
minIndent = Math.min(indent, minIndent);
|
||||
}
|
||||
|
||||
for (var row = cursor.row + 1; row <= end.row; ++row) {
|
||||
var outdent = minIndent;
|
||||
|
||||
|
|
@ -602,19 +603,22 @@ var Editor =function(renderer, doc) {
|
|||
if (this.$readOnly)
|
||||
return;
|
||||
|
||||
var range = this.getSelectionRange();
|
||||
var doc = this.doc,
|
||||
range = this.getSelectionRange();
|
||||
|
||||
if (range.start.row < range.end.row ||
|
||||
range.start.column < range.end.column) {
|
||||
var count = this.doc.indentRows(this.getSelectionRange(), "\t");
|
||||
var count = doc.indentRows(this.getSelectionRange(), "\t");
|
||||
|
||||
this.selection.shiftSelection(count);
|
||||
} else {
|
||||
var indentString;
|
||||
|
||||
if (this.doc.getUseSoftTabs()) {
|
||||
var size = this.doc.getTabSize(),
|
||||
count = (size - this.getCursorPosition().column % size);
|
||||
var size = doc.getTabSize(),
|
||||
position = this.getCursorPosition(),
|
||||
column = doc.documentToScreenColumn(position.row, position.column),
|
||||
count = (size - column % size);
|
||||
|
||||
indentString = lang.stringRepeat(" ", count);
|
||||
} else
|
||||
|
|
@ -623,7 +627,7 @@ var Editor =function(renderer, doc) {
|
|||
}
|
||||
};
|
||||
|
||||
this.blockOutdent = function(indentString) {
|
||||
this.blockOutdent = function() {
|
||||
if (this.$readOnly)
|
||||
return;
|
||||
|
||||
|
|
@ -956,13 +960,14 @@ var Editor =function(renderer, doc) {
|
|||
if (options) {
|
||||
this.$search.set(options);
|
||||
}
|
||||
this.clearSelection();
|
||||
this.selection.moveCursorTo(0, 0);
|
||||
|
||||
var ranges = this.$search.findAll(this.doc);
|
||||
if (!ranges.length)
|
||||
return;
|
||||
|
||||
this.clearSelection();
|
||||
this.selection.moveCursorTo(0, 0);
|
||||
|
||||
for (var i = ranges.length - 1; i >= 0; --i)
|
||||
this.$tryReplace(ranges[i], replacement);
|
||||
if (ranges[0] !== null)
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue