diff --git a/src/components/ModalVault.svelte b/src/components/ModalVault.svelte
index a386a95..e31e14b 100644
--- a/src/components/ModalVault.svelte
+++ b/src/components/ModalVault.svelte
@@ -47,6 +47,7 @@
let openInCurrentPaneKey: string
let createInNewPaneKey: string
let createInCurrentPaneKey: string
+ let openInNewLeafKey: string = getCtrlKeyLabel() + ' alt ↵'
$: selectedNote = resultNotes[selectedIndex]
$: searchQuery = searchQuery ?? previousQuery
@@ -101,6 +102,7 @@
eventBus.on('vault', Action.ArrowDown, () => moveIndex(1))
eventBus.on('vault', Action.PrevSearchHistory, prevSearchHistory)
eventBus.on('vault', Action.NextSearchHistory, nextSearchHistory)
+ eventBus.on('vault', Action.OpenInNewLeaf, openNoteInNewLeaf)
await NotesIndex.refreshIndex()
await updateResultsDebounced()
})
@@ -178,16 +180,26 @@
modal.close()
}
+ function openNoteInNewLeaf(): void {
+ if (!selectedNote) return
+ openSearchResult(selectedNote, true, true)
+ modal.close()
+ }
+
function saveCurrentQuery() {
if (searchQuery) {
cacheManager.addToSearchHistory(searchQuery)
}
}
- function openSearchResult(note: ResultNote, newPane = false) {
+ function openSearchResult(
+ note: ResultNote,
+ newPane = false,
+ newLeaf = false
+ ) {
saveCurrentQuery()
const offset = note.matches?.[0]?.offset ?? 0
- openNote(note, offset, newPane)
+ openNote(note, offset, newPane, newLeaf)
}
async function onClickCreateNote(_e: MouseEvent) {
@@ -354,6 +366,11 @@
to open in a new pane
+
+ {openInNewLeafKey}
+ to open in a new split
+
+
alt o
to open in the background
diff --git a/src/components/modals.ts b/src/components/modals.ts
index d3aa6b2..e313869 100644
--- a/src/components/modals.ts
+++ b/src/components/modals.ts
@@ -68,6 +68,7 @@ abstract class OmnisearchModal extends Modal {
let openInNewPaneKey: Modifier[]
let createInCurrentPaneKey: Modifier[]
let createInNewPaneKey: Modifier[]
+ let openInNewLeafKey: Modifier[] = ['Mod', 'Alt']
if (settings.openInNewPane) {
openInCurrentPaneKey = ['Mod']
openInNewPaneKey = []
@@ -86,6 +87,12 @@ abstract class OmnisearchModal extends Modal {
eventBus.emit(Action.OpenInNewPane)
})
+ // Open in a new leaf
+ this.scope.register(openInNewLeafKey, 'Enter', e => {
+ e.preventDefault()
+ eventBus.emit(Action.OpenInNewLeaf)
+ })
+
// Insert link
this.scope.register(['Alt'], 'Enter', e => {
e.preventDefault()
diff --git a/src/globals.ts b/src/globals.ts
index 2672bb9..8edbfe8 100644
--- a/src/globals.ts
+++ b/src/globals.ts
@@ -43,6 +43,7 @@ export const enum Action {
ArrowDown = 'arrow-down',
PrevSearchHistory = 'prev-search-history',
NextSearchHistory = 'next-search-history',
+ OpenInNewLeaf = 'open-in-new-leaf',
}
export type DocumentRef = { path: string; mtime: number }
diff --git a/src/tools/notes.ts b/src/tools/notes.ts
index d040c4e..2750ae6 100644
--- a/src/tools/notes.ts
+++ b/src/tools/notes.ts
@@ -5,7 +5,8 @@ import { stringsToRegex } from './text-processing'
export async function openNote(
item: ResultNote,
offset = 0,
- newPane = false
+ newPane = false,
+ newLeaf = false
): Promise {
// Check if the note is already open,
// to avoid opening it twice if the first one is pinned
@@ -25,7 +26,7 @@ export async function openNote(
if (!alreadyOpenAndPinned) {
// Open the note normally
- await app.workspace.openLinkText(item.path, '', newPane)
+ await app.workspace.openLinkText(item.path, '', newLeaf ? 'split' : newPane)
}
const view = app.workspace.getActiveViewOfType(MarkdownView)