Skip to content

Commit

Permalink
link: improve matching of correct heading in note links
Browse files Browse the repository at this point in the history
  • Loading branch information
pbek committed Dec 23, 2023
1 parent e03f39c commit 48f8d6b
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 1 deletion.
1 change: 1 addition & 0 deletions CHANGELOG.md
Original file line number Diff line number Diff line change
Expand Up @@ -6,6 +6,7 @@
- toggling the experimental note tree mode in the settings now requires a restart
of the application, to make sure the panels are initialized correctly
(for [#790](https://github.com/pbek/QOwnNotes/issues/790))
- the matching of the correct heading in note links was improved

## 23.12.3
- the speed of link highlighting in lists starting with 4 spaces or more was improved
Expand Down
6 changes: 5 additions & 1 deletion src/utils/urlhandler.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -112,7 +112,11 @@ void UrlHandler::handleNoteUrl(QString urlString, const QString &fragment) {

// jump to the Markdown heading in the note that is represented by the url fragment
if (!fragment.isEmpty()) {
mw->doSearchInNote("\"## " + fragment + "\"");
// Search with a regular expression for the fragment to make sure
// we are searching for the full heading
auto searchTerm = QStringLiteral("## ") + QRegularExpression::escape(fragment) +
QStringLiteral("$");
mw->activeNoteTextEdit()->doSearch(searchTerm, QPlainTextEditSearchWidget::RegularExpressionMode);
mw->activeNoteTextEdit()->searchWidget()->deactivate();
}
} else {
Expand Down

0 comments on commit 48f8d6b

Please sign in to comment.