pressing ctrl+home second time should restore selection

This commit is contained in:
nightwing 2013-06-17 16:35:22 +04:00
commit 52e0b2d163
2 changed files with 25 additions and 5 deletions

View file

@ -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"),

View file

@ -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));