#206 - Added ctrl+enter shortcut for InFile results
This commit is contained in:
@@ -6,7 +6,7 @@
|
|||||||
type ResultNote,
|
type ResultNote,
|
||||||
type SearchMatch,
|
type SearchMatch,
|
||||||
} from 'src/globals'
|
} from 'src/globals'
|
||||||
import { loopIndex } from 'src/tools/utils'
|
import { getCtrlKeyLabel, loopIndex } from 'src/tools/utils'
|
||||||
import { onDestroy, onMount, tick } from 'svelte'
|
import { onDestroy, onMount, tick } from 'svelte'
|
||||||
import { MarkdownView } from 'obsidian'
|
import { MarkdownView } from 'obsidian'
|
||||||
import ModalContainer from './ModalContainer.svelte'
|
import ModalContainer from './ModalContainer.svelte'
|
||||||
@@ -36,6 +36,7 @@
|
|||||||
eventBus.enable('infile')
|
eventBus.enable('infile')
|
||||||
|
|
||||||
eventBus.on('infile', 'enter', openSelection)
|
eventBus.on('infile', 'enter', openSelection)
|
||||||
|
eventBus.on('infile', 'open-in-new-pane', openSelectionInNewTab)
|
||||||
eventBus.on('infile', 'arrow-up', () => moveIndex(-1))
|
eventBus.on('infile', 'arrow-up', () => moveIndex(-1))
|
||||||
eventBus.on('infile', 'arrow-down', () => moveIndex(1))
|
eventBus.on('infile', 'arrow-down', () => moveIndex(1))
|
||||||
eventBus.on('infile', 'tab', switchToVaultModal)
|
eventBus.on('infile', 'tab', switchToVaultModal)
|
||||||
@@ -108,15 +109,17 @@
|
|||||||
elem?.scrollIntoView({ behavior: 'auto', block: 'nearest' })
|
elem?.scrollIntoView({ behavior: 'auto', block: 'nearest' })
|
||||||
}
|
}
|
||||||
|
|
||||||
async function openSelection(
|
async function openSelectionInNewTab(): Promise<void> {
|
||||||
evt?: MouseEvent | KeyboardEvent
|
return openSelection(true)
|
||||||
): Promise<void> {
|
}
|
||||||
|
|
||||||
|
async function openSelection(newTab = false): Promise<void> {
|
||||||
if (note) {
|
if (note) {
|
||||||
modal.close()
|
modal.close()
|
||||||
if (parent) parent.close()
|
if (parent) parent.close()
|
||||||
|
|
||||||
// Open (or switch focus to) the note
|
// Open (or switch focus to) the note
|
||||||
await openNote(note, evt?.ctrlKey)
|
await openNote(note, newTab)
|
||||||
|
|
||||||
// Move cursor to the match
|
// Move cursor to the match
|
||||||
const view = app.workspace.getActiveViewOfType(MarkdownView)
|
const view = app.workspace.getActiveViewOfType(MarkdownView)
|
||||||
@@ -157,7 +160,7 @@
|
|||||||
index="{i}"
|
index="{i}"
|
||||||
selected="{i === selectedIndex}"
|
selected="{i === selectedIndex}"
|
||||||
on:mousemove="{_e => (selectedIndex = i)}"
|
on:mousemove="{_e => (selectedIndex = i)}"
|
||||||
on:click="{openSelection}" />
|
on:click="{(evt) => openSelection(evt.ctrlKey)}" />
|
||||||
{/each}
|
{/each}
|
||||||
{:else}
|
{:else}
|
||||||
<div style="text-align: center;">
|
<div style="text-align: center;">
|
||||||
@@ -185,4 +188,9 @@
|
|||||||
<span>to close</span>
|
<span>to close</span>
|
||||||
{/if}
|
{/if}
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
|
<div class="prompt-instruction">
|
||||||
|
<span class="prompt-instruction-command">{getCtrlKeyLabel()} ↵</span>
|
||||||
|
<span>to open in a new pane</span>
|
||||||
|
</div>
|
||||||
</div>
|
</div>
|
||||||
|
|||||||
@@ -319,8 +319,6 @@
|
|||||||
<span>to switch to In-File Search</span>
|
<span>to switch to In-File Search</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
<div class="prompt-instruction">
|
<div class="prompt-instruction">
|
||||||
<span class="prompt-instruction-command">{getCtrlKeyLabel()} ↵</span>
|
<span class="prompt-instruction-command">{getCtrlKeyLabel()} ↵</span>
|
||||||
<span>to open in a new pane</span>
|
<span>to open in a new pane</span>
|
||||||
@@ -334,8 +332,6 @@
|
|||||||
<span>to create in a new pane</span>
|
<span>to create in a new pane</span>
|
||||||
</div>
|
</div>
|
||||||
|
|
||||||
<br />
|
|
||||||
|
|
||||||
<div class="prompt-instruction">
|
<div class="prompt-instruction">
|
||||||
<span class="prompt-instruction-command">alt ↵</span>
|
<span class="prompt-instruction-command">alt ↵</span>
|
||||||
<span>to insert a link</span>
|
<span>to insert a link</span>
|
||||||
|
|||||||
Reference in New Issue
Block a user