Fixed the scrollIntoView() position

This commit is contained in:
Simon Cambier
2024-01-05 20:59:38 +01:00
parent c5efa2ec90
commit 2ef38bdf26
3 changed files with 6 additions and 6 deletions

View File

@@ -19,6 +19,7 @@
import { Query } from 'src/search/query'
import { openNote } from 'src/tools/notes'
import { searchEngine } from 'src/search/omnisearch'
import { stringsToRegex } from 'src/tools/text-processing'
export let modal: OmnisearchInFileModal
export let parent: OmnisearchVaultModal | null = null
@@ -121,7 +122,9 @@
if (parent) parent.close()
// Open (or switch focus to) the note
await openNote(note, newTab)
const reg = stringsToRegex(note.foundWords)
reg.exec(note.content)
await openNote(note, reg.lastIndex, newTab)
// Move cursor to the match
const view = app.workspace.getActiveViewOfType(MarkdownView)

View File

@@ -186,7 +186,7 @@
function openSearchResult(note: ResultNote, newPane = false) {
saveCurrentQuery()
openNote(note, newPane)
openNote(note, note.matches[0].offset, newPane)
}
async function onClickCreateNote(_e: MouseEvent) {