Fixed some bugs and unit tests pass again
This commit is contained in:
parent
1a5a071c7d
commit
d1bfdba34b
3 changed files with 42 additions and 39 deletions
|
|
@ -50,7 +50,7 @@ var Selection = function(session) {
|
|||
this.clearSelection();
|
||||
this.selectionLead = this.doc.createAnchor(0, 0);
|
||||
this.selectionAnchor = this.doc.createAnchor(0, 0);
|
||||
|
||||
|
||||
var _self = this;
|
||||
this.selectionLead.on("change", function(e) {
|
||||
_self._dispatchEvent("changeCursor");
|
||||
|
|
@ -59,7 +59,7 @@ var Selection = function(session) {
|
|||
if (e.old.row == e.value.row)
|
||||
_self.$updateDesiredColumn();
|
||||
});
|
||||
|
||||
|
||||
this.selectionAnchor.on("change", function() {
|
||||
if (!_self.$isEmpty)
|
||||
_self._dispatchEvent("changeSelection");
|
||||
|
|
@ -382,19 +382,14 @@ var Selection = function(session) {
|
|||
};
|
||||
|
||||
this.moveCursorBy = function(rows, chars) {
|
||||
if (this.session.getUseWrapMode()) {
|
||||
var screenPos = this.session.documentToScreenPosition(
|
||||
this.selectionLead.row,
|
||||
this.selectionLead.column
|
||||
);
|
||||
var screenCol = (chars == 0 && this.$desiredColumn) || screenPos.column;
|
||||
var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenCol);
|
||||
|
||||
this.moveCursorTo(docPos.row, docPos.column + chars, chars == 0);
|
||||
} else {
|
||||
var docColumn = (chars == 0 && this.$desiredColumn) || this.selectionLead.column;
|
||||
this.moveCursorTo(this.selectionLead.row + rows, docColumn + chars, chars == 0);
|
||||
}
|
||||
var screenPos = this.session.documentToScreenPosition(
|
||||
this.selectionLead.row,
|
||||
this.selectionLead.column
|
||||
);
|
||||
var screenCol = (chars == 0 && this.$desiredColumn) || screenPos.column;
|
||||
var docPos = this.session.screenToDocumentPosition(screenPos.row + rows, screenCol);
|
||||
|
||||
this.moveCursorTo(docPos.row, docPos.column + chars, chars == 0);
|
||||
};
|
||||
|
||||
this.moveCursorToPosition = function(position) {
|
||||
|
|
@ -408,11 +403,9 @@ var Selection = function(session) {
|
|||
};
|
||||
|
||||
this.moveCursorToScreen = function(row, column, preventUpdateDesiredColumn) {
|
||||
if (this.session.getUseWrapMode()) {
|
||||
var pos = this.session.screenToDocumentPosition(row, column);
|
||||
row = pos.row;
|
||||
column = pos.column;
|
||||
}
|
||||
var pos = this.session.screenToDocumentPosition(row, column);
|
||||
row = pos.row;
|
||||
column = pos.column;
|
||||
this.moveCursorTo(row, column, preventUpdateDesiredColumn);
|
||||
};
|
||||
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue