From e1cd09df3670f0548dc98539efbdc95d2f0d46c3 Mon Sep 17 00:00:00 2001 From: zadam Date: Fri, 3 Jun 2022 09:42:35 +0200 Subject: [PATCH] implement shift-click to select notes in between clicked and active note, closes #2647 --- src/public/app/widgets/note_tree.js | 28 +++++++++++++++++++++++++++- 1 file changed, 27 insertions(+), 1 deletion(-) diff --git a/src/public/app/widgets/note_tree.js b/src/public/app/widgets/note_tree.js index d8caaac4c..1b365074a 100644 --- a/src/public/app/widgets/note_tree.js +++ b/src/public/app/widgets/note_tree.js @@ -309,13 +309,39 @@ export default class NoteTreeWidget extends NoteContextAwareWidget { if (targetType === 'title' || targetType === 'icon') { if (event.shiftKey) { - node.setSelected(!node.isSelected()); + const activeNode = this.getActiveNode(); + + if (activeNode.getParent() !== node.getParent()) { + return; + } + + this.clearSelectedNodes(); + + function selectInBetween(first, second) { + for (let i = 0; first && first !== second && i < 10000; i++) { + first.setSelected(true); + first = first.getNextSibling(); + } + + second.setSelected(); + } + + if (activeNode.getIndex() < node.getIndex()) { + selectInBetween(activeNode, node); + } else { + selectInBetween(node, activeNode); + } + node.setFocus(true); } else if (event.ctrlKey) { const notePath = treeService.getNotePath(node); appContext.tabManager.openTabWithNoteWithHoisting(notePath); } + else if (event.altKey) { + node.setSelected(!node.isSelected()); + node.setFocus(true); + } else if (data.node.isActive()) { // this is important for single column mobile view, otherwise it's not possible to see again previously displayed note this.tree.reactivate(true);