Fixed the scrollIntoView() position
This commit is contained in:
@@ -19,6 +19,7 @@
|
|||||||
import { Query } from 'src/search/query'
|
import { Query } from 'src/search/query'
|
||||||
import { openNote } from 'src/tools/notes'
|
import { openNote } from 'src/tools/notes'
|
||||||
import { searchEngine } from 'src/search/omnisearch'
|
import { searchEngine } from 'src/search/omnisearch'
|
||||||
|
import { stringsToRegex } from 'src/tools/text-processing'
|
||||||
|
|
||||||
export let modal: OmnisearchInFileModal
|
export let modal: OmnisearchInFileModal
|
||||||
export let parent: OmnisearchVaultModal | null = null
|
export let parent: OmnisearchVaultModal | null = null
|
||||||
@@ -121,7 +122,9 @@
|
|||||||
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, newTab)
|
const reg = stringsToRegex(note.foundWords)
|
||||||
|
reg.exec(note.content)
|
||||||
|
await openNote(note, reg.lastIndex, newTab)
|
||||||
|
|
||||||
// Move cursor to the match
|
// Move cursor to the match
|
||||||
const view = app.workspace.getActiveViewOfType(MarkdownView)
|
const view = app.workspace.getActiveViewOfType(MarkdownView)
|
||||||
|
|||||||
@@ -186,7 +186,7 @@
|
|||||||
|
|
||||||
function openSearchResult(note: ResultNote, newPane = false) {
|
function openSearchResult(note: ResultNote, newPane = false) {
|
||||||
saveCurrentQuery()
|
saveCurrentQuery()
|
||||||
openNote(note, newPane)
|
openNote(note, note.matches[0].offset, newPane)
|
||||||
}
|
}
|
||||||
|
|
||||||
async function onClickCreateNote(_e: MouseEvent) {
|
async function onClickCreateNote(_e: MouseEvent) {
|
||||||
|
|||||||
@@ -4,12 +4,9 @@ import { stringsToRegex } from './text-processing'
|
|||||||
|
|
||||||
export async function openNote(
|
export async function openNote(
|
||||||
item: ResultNote,
|
item: ResultNote,
|
||||||
|
offset = 0,
|
||||||
newPane = false
|
newPane = false
|
||||||
): Promise<void> {
|
): Promise<void> {
|
||||||
const reg = stringsToRegex(item.foundWords)
|
|
||||||
reg.exec(item.content)
|
|
||||||
const offset = reg.lastIndex
|
|
||||||
|
|
||||||
// Check if the note is already open,
|
// Check if the note is already open,
|
||||||
// to avoid opening it twice if the first one is pinned
|
// to avoid opening it twice if the first one is pinned
|
||||||
let alreadyOpenAndPinned = false
|
let alreadyOpenAndPinned = false
|
||||||
|
|||||||
Reference in New Issue
Block a user