From e611202da2c7f84dfa216f78c0e6c2e35db1d9e2 Mon Sep 17 00:00:00 2001 From: Simon Cambier Date: Thu, 9 Mar 2023 21:29:09 +0100 Subject: [PATCH] #206 - Added ctrl+enter shortcut for InFile results --- src/components/ModalInFile.svelte | 20 ++++++++++++++------ src/components/ModalVault.svelte | 4 ---- 2 files changed, 14 insertions(+), 10 deletions(-) diff --git a/src/components/ModalInFile.svelte b/src/components/ModalInFile.svelte index 8079472..02c9ba6 100644 --- a/src/components/ModalInFile.svelte +++ b/src/components/ModalInFile.svelte @@ -6,7 +6,7 @@ type ResultNote, type SearchMatch, } from 'src/globals' - import { loopIndex } from 'src/tools/utils' + import { getCtrlKeyLabel, loopIndex } from 'src/tools/utils' import { onDestroy, onMount, tick } from 'svelte' import { MarkdownView } from 'obsidian' import ModalContainer from './ModalContainer.svelte' @@ -36,6 +36,7 @@ eventBus.enable('infile') eventBus.on('infile', 'enter', openSelection) + eventBus.on('infile', 'open-in-new-pane', openSelectionInNewTab) eventBus.on('infile', 'arrow-up', () => moveIndex(-1)) eventBus.on('infile', 'arrow-down', () => moveIndex(1)) eventBus.on('infile', 'tab', switchToVaultModal) @@ -108,15 +109,17 @@ elem?.scrollIntoView({ behavior: 'auto', block: 'nearest' }) } - async function openSelection( - evt?: MouseEvent | KeyboardEvent - ): Promise { + async function openSelectionInNewTab(): Promise { + return openSelection(true) + } + + async function openSelection(newTab = false): Promise { if (note) { modal.close() if (parent) parent.close() // Open (or switch focus to) the note - await openNote(note, evt?.ctrlKey) + await openNote(note, newTab) // Move cursor to the match const view = app.workspace.getActiveViewOfType(MarkdownView) @@ -157,7 +160,7 @@ index="{i}" selected="{i === selectedIndex}" on:mousemove="{_e => (selectedIndex = i)}" - on:click="{openSelection}" /> + on:click="{(evt) => openSelection(evt.ctrlKey)}" /> {/each} {:else}
@@ -185,4 +188,9 @@ to close {/if}
+ +
+ {getCtrlKeyLabel()} ↵ + to open in a new pane +
diff --git a/src/components/ModalVault.svelte b/src/components/ModalVault.svelte index 9772cf2..8deab51 100644 --- a/src/components/ModalVault.svelte +++ b/src/components/ModalVault.svelte @@ -319,8 +319,6 @@ to switch to In-File Search -
-
{getCtrlKeyLabel()} ↵ to open in a new pane @@ -334,8 +332,6 @@ to create in a new pane
-
-
alt ↵ to insert a link