-
Notifications
You must be signed in to change notification settings - Fork 565
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
Add missing decorators in note list previews #1814
Conversation
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.
Works great.
When showing each item in the note list we run the content decorators on them in order to show checkboxes instead of the markdown syntax for a checkbox and we also highlight the matching text from the search box. Previously we have only been showing the first match for each decorator because of a couple small bugs: - the task prefix matcher wasn't using the `m` multi-line flag in its RegExp pattern - the search filter text was only replacing the first occurrance, see JS "replaceAll()" proposal In this patch we're rewritten `decorateWith` to automatically create a global RegExp pattern for the search text and the task prefix RegExp pattern has been corrected. After this patch you can now see all of the decorated items in the note list; for example, if you had two checklist items in a note then you can now see multiple checkboxes in the note list whereas before you'd only see the first one and then the second one would appear as ` - [ ]` or `- [x]`
a496888
to
7da052e
Compare
Rebased to catch renames from #1813 in |
@@ -3,6 +3,6 @@ export const selectors = { | |||
markdownRoot: '[data-markdown-root]', | |||
}; | |||
|
|||
export const taskPrefixRegex = /^(\s*)(-[ \t]+\[[xX\s]?\])/g; | |||
export const taskPrefixRegex = /^(\s*)(-[ \t]+\[[xX\s]?\])/gm; |
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.
@mirka can you remember if there was any specific reason not to include all search results here by adding the m
? I didn't see any mention of it in the commit log but I don't want to accidentally introduce a bug you intentionally avoided.
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.
It seems like between the time I added this regex and now, the behavior of the Comfy
/Expanded
note list views have changed. Before, it showed the title and only the first line of the body, with Expanded
showing more of the first line if it was a long paragraph. Now, it's concatenating multiple lines of the body if the lines are short.
So back then we didn't need the m
flag, simply because a note body preview would never show more than one task item line. (In that sense, it's actually the g
flag that was superfluous!)
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.
ah! that makes sense. we did update the preview generation so that it would show the start of the first few lines of the note instead of collapsing them. we missed the impact here then when we made that change.
thanks for chiming in and helping @mirka!
When showing each item in the note list we run the content decorators on them
in order to show checkboxes instead of the markdown syntax for a checkbox and
we also highlight the matching text from the search box.
Previously we have only been showing the first match for each decorator because
of a couple small bugs:
m
multi-line flag in its RegExppattern
"replaceAll()" proposal
In this patch we're rewritten
decorateWith
to automatically create a globalRegExp pattern for the search text and the task prefix RegExp pattern has been
corrected.
After this patch you can now see all of the decorated items in the note list;
for example, if you had two checklist items in a note then you can now see
multiple checkboxes in the note list whereas before you'd only see the first
one and then the second one would appear as
- [ ]
or- [x]
Testing
Open an account with notes having multiple repeated text in the first few lines.
For example…(
one
appears in each line)Search for the repeated pattern, such as
one
You should find that in develop you'll only see the first result highlighted
but in this branch all of the
one
s should be highlighted.Repeat the experiment with a checklist…
In develop only the first item will render as a checklist but in this branch
all three should, if they are visible in the preview.
Verify that if you search for regular-expression-y patterns then you'll only
get results matching the literal text and not the pattern itself.
If you search for
\d
then the\d
in the note should be highlighted, not the4
Before
After