Merge pull request #114 from tophf/respect-user-extrakeys
Respect localStorage::editor.extraKeys user option
This commit is contained in:
commit
28e34f2990
15
edit.js
15
edit.js
|
@ -159,20 +159,33 @@ function initCodeMirror() {
|
|||
|
||||
// "basic" keymap only has basic keys by design, so we skip it
|
||||
|
||||
var extraKeysCommands = {};
|
||||
if (userOptions && typeof userOptions.extraKeys == "object") {
|
||||
Object.keys(userOptions.extraKeys).forEach(function(key) {
|
||||
extraKeysCommands[userOptions.extraKeys[key]] = true;
|
||||
});
|
||||
}
|
||||
if (!extraKeysCommands.jumpToLine) {
|
||||
CM.keyMap.sublime["Ctrl-G"] = "jumpToLine";
|
||||
CM.keyMap.emacsy["Ctrl-G"] = "jumpToLine";
|
||||
CM.keyMap.pcDefault["Ctrl-J"] = "jumpToLine";
|
||||
CM.keyMap.macDefault["Cmd-J"] = "jumpToLine";
|
||||
|
||||
}
|
||||
if (!extraKeysCommands.autocomplete) {
|
||||
CM.keyMap.pcDefault["Ctrl-Space"] = "autocomplete"; // will be used by "sublime" on PC via fallthrough
|
||||
CM.keyMap.macDefault["Alt-Space"] = "autocomplete"; // OSX uses Ctrl-Space and Cmd-Space for something else
|
||||
CM.keyMap.emacsy["Alt-/"] = "autocomplete"; // copied from "emacs" keymap
|
||||
// "vim" and "emacs" define their own autocomplete hotkeys
|
||||
}
|
||||
|
||||
if (isWindowsOS) {
|
||||
// "pcDefault" keymap on Windows should have F3/Shift-F3
|
||||
if (!extraKeysCommands.findNext) {
|
||||
CM.keyMap.pcDefault["F3"] = "findNext";
|
||||
}
|
||||
if (!extraKeysCommands.findPrev) {
|
||||
CM.keyMap.pcDefault["Shift-F3"] = "findPrev";
|
||||
}
|
||||
|
||||
// try to remap non-interceptable Ctrl-(Shift-)N/T/W hotkeys
|
||||
["N", "T", "W"].forEach(function(char) {
|
||||
|
|
Loading…
Reference in New Issue
Block a user