diff --git a/lib/ace/commands/default_commands.js b/lib/ace/commands/default_commands.js index 9d3bc401..24e03a90 100644 --- a/lib/ace/commands/default_commands.js +++ b/lib/ace/commands/default_commands.js @@ -118,13 +118,15 @@ exports.commands = [{ bindKey: bindKey("Ctrl-Shift-Home", "Command-Shift-Up"), exec: function(editor) { editor.getSelection().selectFileStart(); }, multiSelectAction: "forEach", - readOnly: true + readOnly: true, + group: "fileJump" }, { name: "gotostart", bindKey: bindKey("Ctrl-Home", "Command-Home|Command-Up"), exec: function(editor) { editor.navigateFileStart(); }, multiSelectAction: "forEach", - readOnly: true + readOnly: true, + group: "fileJump" }, { name: "selectup", bindKey: bindKey("Shift-Up", "Shift-Up"), @@ -142,13 +144,15 @@ exports.commands = [{ bindKey: bindKey("Ctrl-Shift-End", "Command-Shift-Down"), exec: function(editor) { editor.getSelection().selectFileEnd(); }, multiSelectAction: "forEach", - readOnly: true + readOnly: true, + group: "fileJump" }, { name: "gotoend", bindKey: bindKey("Ctrl-End", "Command-End|Command-Down"), exec: function(editor) { editor.navigateFileEnd(); }, multiSelectAction: "forEach", - readOnly: true + readOnly: true, + group: "fileJump" }, { name: "selectdown", bindKey: bindKey("Shift-Down", "Shift-Down"), diff --git a/lib/ace/editor.js b/lib/ace/editor.js index 6771c0dd..572425ea 100644 --- a/lib/ace/editor.js +++ b/lib/ace/editor.js @@ -107,11 +107,27 @@ var Editor = function(renderer, session) { this.commands.on("exec", function(e) { this.startOperation(e); + var command = e.command; + if (command.group == "fileJump") { + var prev = this.prevOp; + if (!prev || prev.command.group != "fileJump") { + this.lastFileJumpPos = last(this.selections) + } + } else { + this.lastFileJumpPos = null; + } }.bind(this), true); this.commands.on("afterExec", function(e) { - this.endOperation(e); + var command = e.command; + if (command.group == "fileJump") { + if (this.lastFileJumpPos && !this.curOp.selectionChanged) { + this.selection.fromJSON(this.lastFileJumpPos); + return + } + } + this.endOperation(e); }.bind(this), true); this.$opResetTimer = lang.delayedCall(this.endOperation.bind(this));