-
-
Notifications
You must be signed in to change notification settings - Fork 5.1k
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Desktop: Resolves #9927: Beta editor: Fix search results not highlighted #9928
Desktop: Resolves #9927: Beta editor: Fix search results not highlighted #9928
Conversation
@@ -172,7 +176,7 @@ export default function useEditorSearch(CodeMirror: any) { | |||
// These operations are pretty slow, so we won't add use them until the user | |||
// has finished typing, 500ms is probably enough time | |||
const timeout = shim.setTimeout(() => { | |||
const scrollMarks = this.showMatchesOnScrollbar(searchTerm, true, 'cm-search-marker-scrollbar'); | |||
const scrollMarks = this.showMatchesOnScrollbar?.(searchTerm, true, 'cm-search-marker-scrollbar'); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
At present, showMatchesOnScrollbar
is only implemented for CodeMirror 5. As per this discussion thread, we'll likely need to implement this ourselves.
renderedBody: RenderedBody; | ||
} | ||
|
||
const useEditorSearchHandler = (props: Props) => { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
useEditorSearchHandler
was originally part of v5/CodeMirror.tsx
.
} | ||
|
||
if (match) { | ||
if (scrollTo) { | ||
if (withSelection) { | ||
cm.setSelection(match.from, match.to); | ||
} else { | ||
cm.scrollTo(match); | ||
cm.scrollIntoView(match); |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
According to the CodeMirror documentation, .scrollTo
takes two arguments, while scrollIntoView
can take an object with the same type as match
.
As such, I suspect we were calling scrollTo
incorrectly.
@personalizedrefrigerator there's one conflict here as well |
Sorry, a few more conflicts now |
It's complaining about a spelling mistake:
|
Summary
CodeMirror5Emulation
such that Joplin's CodeMirror 5 search highlighting works with CodeMirror 6.Fixes #9927.
Testing
Enable the CodeMirror 5 editor
Search for a full-word term known to be present in multiple notes (e.g. "references")
Change the search term to work around Desktop: Search matches sometimes not shown in CM5 editor #9926
Verify that matches are shown on the scrollbar
Verify that matches are highlighted in both the editor and viewer
Enable the CodeMirror 6 editor
Search for "references"
Change the search term to work around Desktop: Search matches sometimes not shown in CM5 editor #9926
Verify that matches are highlighted in both the editor and viewer
This has been tested successfully on Ubuntu 23.10.