Skip to content

Commit

Permalink
fix(slap-editor#164): update editor on selection change
Browse files Browse the repository at this point in the history
  • Loading branch information
dbkaplun committed Jun 11, 2015
1 parent 5914cfc commit 408dfd2
Showing 1 changed file with 7 additions and 5 deletions.
12 changes: 7 additions & 5 deletions lib/ui/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -592,11 +592,13 @@ Editor.prototype._initHandlers = function () {

self.textBuf.on('path-changed', function () { self.language(extname(self.textBuf.getPath()).slice(1)); });

selection.emitter.on('did-change', function () {
var cursor = self.visiblePos(selection.getHeadPosition());
if (self.data.updatePreferredX) self.data.preferredCursorX = cursor.column; // preferred X when moving vertically
self._markMatches();
self.clipScroll([cursor]);
[selection, selection.emitter].forEach(function (eventEmitter) {
eventEmitter.on('did-change', function () {
var cursor = self.visiblePos(selection.getHeadPosition());
if (self.data.updatePreferredX) self.data.preferredCursorX = cursor.column; // preferred X when moving vertically
self._markMatches();
self.clipScroll([cursor]);
});
});

['path-changed', 'changed'].forEach(function (evt) {
Expand Down

0 comments on commit 408dfd2

Please sign in to comment.