Skip to content

Commit

Permalink
Define 'singleSelection' command, bind Esc to it by default
Browse files Browse the repository at this point in the history
Issue #778
  • Loading branch information
marijnh committed Jan 16, 2014
1 parent ea4a1a6 commit ae88a3b
Show file tree
Hide file tree
Showing 2 changed files with 5 additions and 6 deletions.
5 changes: 0 additions & 5 deletions keymap/multiselect.js
Original file line number Diff line number Diff line change
Expand Up @@ -36,11 +36,6 @@
cm.addSelection(cur.from(), cur.to());
};

// Go to a single selection
pc["Alt-Esc"] = mac["Alt-Esc"] = function(cm) {
cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"));
};

// Select matching parts of current selection
var dialogText = 'Match: <input type="text" style="width: 10em"/> <span style="color: #888">(Use /re/ syntax for regexp)</span>';
pc["Alt-F"] = mac["Alt-F"] = function(cm) {
Expand Down
6 changes: 5 additions & 1 deletion lib/codemirror.js
Original file line number Diff line number Diff line change
Expand Up @@ -3757,6 +3757,9 @@

var commands = CodeMirror.commands = {
selectAll: function(cm) {cm.setSelection(Pos(cm.firstLine(), 0), Pos(cm.lastLine()));},
singleSelection: function(cm) {
cm.setSelection(cm.getCursor("anchor"), cm.getCursor("head"));
},
killLine: function(cm) {
deleteNearSelection(cm, function(range) {
if (range.empty()) {
Expand Down Expand Up @@ -3876,7 +3879,8 @@
"End": "goLineEnd", "Home": "goLineStartSmart", "PageUp": "goPageUp", "PageDown": "goPageDown",
"Delete": "delCharAfter", "Backspace": "delCharBefore", "Shift-Backspace": "delCharBefore",
"Tab": "defaultTab", "Shift-Tab": "indentAuto",
"Enter": "newlineAndIndent", "Insert": "toggleOverwrite"
"Enter": "newlineAndIndent", "Insert": "toggleOverwrite",
"Esc": "singleSelection"
};
// Note that the save and find-related commands aren't defined by
// default. Unknown commands are simply ignored.
Expand Down

0 comments on commit ae88a3b

Please sign in to comment.