From 47503fddfe3275485fd012c6c08f197859a63667 Mon Sep 17 00:00:00 2001 From: Le Tan Date: Wed, 25 Jul 2018 21:54:36 +0800 Subject: [PATCH] TagExplorer: use RegularExpression instead of WholeWordOnly when searching for a tag "\bc#\b" won't match a word. We use "^c#$" instead. --- src/vtagexplorer.cpp | 9 ++++++--- 1 file changed, 6 insertions(+), 3 deletions(-) diff --git a/src/vtagexplorer.cpp b/src/vtagexplorer.cpp index cb038ead..8c97a6de 100644 --- a/src/vtagexplorer.cpp +++ b/src/vtagexplorer.cpp @@ -223,13 +223,16 @@ bool VTagExplorer::activateTag(const QString &p_tag) QVector notebooks; notebooks.append(m_notebook); getVSearch()->clear(); + // We could not use WholeWordOnly here, since "c#" won't match a word. + int opts = VSearchConfig::CaseSensitive | VSearchConfig::RegularExpression; + QString pattern = QRegExp::escape(p_tag); + pattern = "^" + pattern + "$"; QSharedPointer config(new VSearchConfig(VSearchConfig::CurrentNotebook, VSearchConfig::Tag, VSearchConfig::Note, VSearchConfig::Internal, - VSearchConfig::CaseSensitive - | VSearchConfig::WholeWordOnly, - p_tag, + opts, + pattern, QString())); getVSearch()->setConfig(config); QSharedPointer result = getVSearch()->search(notebooks);