fix desired column computation

This commit is contained in:
Fabian Jakobs 2011-02-12 13:13:35 +01:00
commit 32a332fd3f
2 changed files with 13 additions and 5 deletions

View file

@ -138,9 +138,17 @@ var Anchor = exports.Anchor = function(doc, row, column) {
if (this.row == pos.row && this.column == pos.column) if (this.row == pos.row && this.column == pos.column)
return; return;
var old = {
row: this.row,
column: this.column
};
this.row = pos.row; this.row = pos.row;
this.column = pos.column; this.column = pos.column;
this._dispatchEvent("change"); this._dispatchEvent("change", {
old: old,
value: pos
});
}; };
this.detach = function() { this.detach = function() {

View file

@ -53,10 +53,12 @@ var Selection = function(session) {
this.selectionAnchor = new Anchor(this.doc, 0, 0); this.selectionAnchor = new Anchor(this.doc, 0, 0);
var _self = this; var _self = this;
this.selectionLead.on("change", function() { this.selectionLead.on("change", function(e) {
_self._dispatchEvent("changeCursor"); _self._dispatchEvent("changeCursor");
if (!_self.$isEmpty) if (!_self.$isEmpty)
_self._dispatchEvent("changeSelection"); _self._dispatchEvent("changeSelection");
if (e.old.row == e.value.row)
_self.$updateDesiredColumn();
}); });
this.selectionAnchor.on("change", function() { this.selectionAnchor.on("change", function() {
@ -176,9 +178,7 @@ var Selection = function(session) {
this.$updateDesiredColumn = function() { this.$updateDesiredColumn = function() {
var cursor = this.getCursor(); var cursor = this.getCursor();
if (cursor) { this.$desiredColumn = this.session.documentToScreenColumn(cursor.row, cursor.column);
this.$desiredColumn = this.session.documentToScreenColumn(cursor.row, cursor.column);
}
}; };
this.$moveSelection = function(mover) { this.$moveSelection = function(mover) {