add clear all highlight shortkey

This commit is contained in:
Xen 2020-05-25 21:55:47 +08:00
parent 7e2ed2af55
commit 4390afa8c8
1 changed files with 30 additions and 0 deletions

View File

@ -139,6 +139,23 @@ function highlightToggle() {
return null;
}
function hightlightClearAll() {
console.log("highlight clear all");
let model = editor.getModel();
let decos = model.getAllDecorations();
for (let deco of decos) {
if (deco.options.className === null) continue;
if (
deco.options.className.indexOf("hl-") !== -1 ||
deco.options.className === "hex-select"
) {
model.deltaDecorations([deco.id], []);
}
}
}
function openFile() {
dialog
.showOpenDialog({
@ -464,6 +481,19 @@ amdRequire(["vs/editor/editor.main"], function () {
run: highlightToggle,
});
editor.addAction({
id: "highlight-clear-all",
label: "Highlight Clear All",
keybindings: [
monaco.KeyMod.CtrlCmd + monaco.KeyMod.Shift + monaco.KeyCode.KEY_E,
],
precondition: null,
keybindingContext: null,
contextMenuGroupId: "9_cutcopypaste",
contextMenuOrder: 1.5,
run: hightlightClearAll,
});
editor.addCommand(monaco.KeyMod.CtrlCmd + monaco.KeyCode.KEY_W, () => {
// Do nothing but prevent default action: close window
});