Skip to content

Commit

Permalink
Scroll to proper position after strip WS on save. Closes #322
Browse files Browse the repository at this point in the history
  • Loading branch information
sergi committed Dec 1, 2011
1 parent 1e73761 commit 39c0e84
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions client/ext/stripws/stripws.js
Expand Up @@ -29,6 +29,7 @@ var strip = module.exports.strip = function () {
var selection = session.getSelection();
var result = source.replace(RE_WS, "\n");
var pos, lead, anchor;
var scrollTopRow = editor.renderer.getScrollTopRow();

// Check whether the user has text selected
if (!selection.isEmpty()) {
Expand All @@ -42,16 +43,16 @@ var strip = module.exports.strip = function () {
session.setValue(result);

if (lead && anchor) {
var selection = session.getSelection();

selection = session.getSelection();
selection.setSelectionAnchor(anchor.row, anchor.column);
selection.moveCursorTo(lead.row, lead.column);
} else if (pos) {
editor.moveCursorTo(pos.row, pos.column);
}
editor.renderer.scrollToRow(scrollTopRow);

return result;
}
};

module.exports = ext.register("ext/stripws/stripws", {
name: "Strip Whitespace",
Expand Down

0 comments on commit 39c0e84

Please sign in to comment.