Skip to content

Commit

Permalink
remember scroll position on saving space trimming #130
Browse files Browse the repository at this point in the history
  • Loading branch information
olsender committed Apr 17, 2019
1 parent ead970d commit e95daf2
Showing 1 changed file with 2 additions and 0 deletions.
2 changes: 2 additions & 0 deletions src/Editor.js
Original file line number Diff line number Diff line change
Expand Up @@ -343,6 +343,7 @@ var Editor = React.createClass({
fileSaveHandler: function(){
var self = this;
var position = self.editor.getCursorPosition();
var scrollRow = self.editor.renderer.getScrollTopRow();
filename = TabsStore.getEditorFile(this.props.eventKey);
var content = self.editor.getValue().replace(/[^\S\r\n]+$/gm, ""); // trim trailing spaces
fs.writeFile(filename, content, function(err) {
Expand All @@ -352,6 +353,7 @@ var Editor = React.createClass({
self.editor.session.setValue(content);
self.editor.clearSelection();
self.editor.gotoLine(position.row+1, 0);
self.editor.renderer.scrollToRow(scrollRow);
}
});
},
Expand Down

0 comments on commit e95daf2

Please sign in to comment.