monkeypatch next/prevBookmark commands to use jumpToPos

This commit is contained in:
tophf 2020-11-24 15:16:29 +03:00
parent 657798d219
commit c635f2e38c

View File

@ -405,6 +405,14 @@
const BRAND = 'sublimeBookmark';
const CLICK_AREA = 'CodeMirror-linenumbers';
const {markText} = CodeMirror.prototype;
for (const name of ['prevBookmark', 'nextBookmark']) {
const cmdFn = CodeMirror.commands[name];
CodeMirror.commands[name] = cm => {
cm.setSelection = cm.jumpToPos;
cmdFn(cm);
delete cm.setSelection;
};
}
CodeMirror.defineInitHook(cm => {
cm.on('gutterClick', onGutterClick);
cm.on('gutterContextMenu', onGutterContextMenu);
@ -446,9 +454,7 @@
}
function onGutterContextMenu(cm, line, name, e) {
if (name === CLICK_AREA) {
cm.setSelection = cm.jumpToPos;
cm.execCommand(e.ctrlKey ? 'prevBookmark' : 'nextBookmark');
delete cm.setSelection;
e.preventDefault();
}
}