Skip to content

Search: no lag on a big book, the last result pressed stays, Ctrl+F (#400) - #407

Merged
Joost-8 merged 4 commits into
mainfrom
fix-search-400
Dec 3, 2026
Merged

Joost-8 merged 4 commits into
mainfrom
fix-search-400

Conversation

@Joost-8

@Joost-8 Joost-8 commented Dec 3, 2026 •

Copy link
Copy Markdown
Owner

For discussion #400 (the search items).

What changed

  • Search no longer lags on a big book. I measured this in real Obsidian on a 1,114-page textbook with the CPU slowed 4×. The text matching took a few ms. The browser building rows took the rest. The sidebar made 150 new rows on every key, and again each time 8 more PDF pages were read. The original list made 500 rows on every key.
    • search-rows.ts: 30 rows are kept and rewritten in place. More are added as you scroll, or until the list fills its height.
    • A text batch that changes no result draws nothing (sameResults).
    • The original list fills rows past the first 12 only as they come into view (lazy-rows.ts, using the list's own window's observer so popouts work).
  • The last result pressed stays. showSearchHits reads the page's text before it moves the view, and nothing let the newest press win, so a slow earlier read moved the view back. search-jump.ts lets only the newest jump move the view, and a touch or scroll on the page cancels it. Each row also records the result under the press, so a list rewritten during a tap still opens what was pressed.
  • Ctrl/⌘+F opens search in a notebook. On main it did nothing (Obsidian's Find works only in markdown).
    • It is a new Settings › Shortcuts row (view.search, under View and zoom) and a new line on the shortcut sheet.
    • It gives way when the user recorded Mod+F for another FineNotes row.
    • It also gives way when the user put Mod+F on an Obsidian command that would run with a notebook open (find-key.ts).

Proof

Measured in the rig: Obsidian 1.15.1, the 1,114-page book, CPU 4×.

main branch
One key, sidebar 600–1,260 ms (style and layout 400–1,000 ms) 20–60 ms; the first one or two letters 100–400 ms
One key, original list 2,400–2,500 ms 270–300 ms
Reading the book's text with search open: main thread blocked 69.0 s in 244 tasks, 100 over 200 ms, longest 907 ms 1.7–3.3 s, none over 220 ms
Quick presses on results (same sequences) earlier results moved the view 2–4 s late; one run ended on p. 167 with p. 398 pressed no late moves
Ctrl+F in a notebook nothing panel opens, cursor in the field; with a custom Obsidian hotkey on Mod+F, that command runs

On the iPad, over the bridge (the vault build plus this branch, the same book, synthetic touch):

before branch
One key, text already read 70–110 ms 31–52 ms
One key while the book is read from scratch 6–20 ms, one 431 ms 4–12 ms, one 475 ms
Five quick presses, three searches always ends on the last one pressed; the view only glides toward it

Still on the iPad: while the whole book is read from scratch, frames stall for about 30 s of 35 s, with gaps up to 3.3 s, with or without this branch and with search closed. JavaScript timers keep running meanwhile (worst gap 13 ms), and each page waits on the PDF worker for about 140 ms. So the stall is in painting during the PDF worker read, not in search. The text is kept on the device after one read, so this happens once per PDF. I left it to the PDF session (pdf-worker.ts).

  • npm run gates passes.
  • New tests: search-rows, search-jump (InkView.showSearchHits: the last press wins, a touch cancels), find-key, plus a shortcut-bindings case, sameResults, and the settings list count.
  • check.mjs --changed: the findings are the 7 groups the nightly already fails on main.
  • Review page: https://claude.ai/artifact/Rayfv6PAMFqzps2Xrkkf92. The shortcut sheet gains one line; the search list looks the same, and its shots are identical.

Test on the device

  1. Open a big PDF notebook and open search. Type a word letter by letter: results come at once, and typing never stalls.
  2. Press four or five results quickly, one after another: the view ends on the last one pressed and stays there.
  3. With a keyboard, press ⌘F in the notebook: search opens with the cursor in the field.

Not verified

  • On the iPad: a real Pencil pressing rows (the bridge taps are synthetic), and ⌘F from the iPad keyboard.
  • The stalled frames while a whole PDF is first read (above), which is outside search.
  • A palm resting on the page while the Pencil presses a result cancels that jump's highlight. This is untested, and most likely to show on Android.
  • If Mod+F is recorded for another row, the Search row in Settings shows no key and gives no reason.

🤖 Generated with Claude Code

Joost-8 and others added 3 commits December 3, 2026 00:07
…400)

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
…count

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
- CHANGELOG: the #400 lines in main's sections, no copied block
- Lazy list rows use the list's own window's observer (popouts)
- The sidebar fills rows until it overflows, not only on scroll
- Ctrl/Cmd+F gives way only to an Obsidian command that runs in a
  notebook, never when the user recorded it under Settings > Shortcuts;
  hotkeys stored as code KeyF count

Co-Authored-By: Claude Opus 5.5 <noreply@anthropic.com>
@Joost-8
Joost-8 marked this pull request as ready for review December 3, 2026 18:03
@Joost-8
Joost-8 merged commit a4231aa into main Dec 3, 2026
1 check passed
@Joost-8
Joost-8 deleted the fix-search-400 branch December 3, 2026 18:10
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

1 participant