From e40b250d13b80fe2fed66b20266deafb14ac5df1 Mon Sep 17 00:00:00 2001 From: Eike Ziller Date: Mon, 20 Aug 2018 13:01:32 +0200 Subject: [PATCH] Add line/column number handling to spotlight locator filter Otherwise it is not possible to directly open a file at a location with the spotlight filter (in the style of "md qwidget.cpp:100"). Task-number: QTCREATORBUG-20473 Change-Id: I9ee70c411f77ca715ebba864ef16eab7c9b31bde Reviewed-by: David Schulz --- .../coreplugin/locator/spotlightlocatorfilter.mm | 12 +++++++----- 1 file changed, 7 insertions(+), 5 deletions(-) diff --git a/src/plugins/coreplugin/locator/spotlightlocatorfilter.mm b/src/plugins/coreplugin/locator/spotlightlocatorfilter.mm index 12794d780f6..f8cdd8189e6 100644 --- a/src/plugins/coreplugin/locator/spotlightlocatorfilter.mm +++ b/src/plugins/coreplugin/locator/spotlightlocatorfilter.mm @@ -25,6 +25,7 @@ #include "spotlightlocatorfilter.h" +#include #include #include @@ -180,19 +181,20 @@ void SpotlightIterator::ensureNext() void SpotlightLocatorFilter::prepareSearch(const QString &entry) { - if (entry.isEmpty()) { + const EditorManager::FilePathInfo fp = EditorManager::splitLineAndColumnNumber(entry); + if (fp.filePath.isEmpty()) { setFileIterator(new BaseFileFilter::ListIterator(QStringList())); } else { // only pass the file name part to spotlight to allow searches like "somepath/*foo" - int lastSlash = entry.lastIndexOf(QLatin1Char('/')); - QString quoted = entry.mid(lastSlash + 1); + int lastSlash = fp.filePath.lastIndexOf(QLatin1Char('/')); + QString quoted = fp.filePath.mid(lastSlash + 1); quoted.replace(QLatin1Char('\\'), QLatin1String("\\\\")) .replace(QLatin1Char('\''), QLatin1String("\\\'")) .replace(QLatin1Char('\"'), QLatin1String("\\\"")); setFileIterator(new SpotlightIterator( QString::fromLatin1("kMDItemFSName like%1 \"*%2*\"") - .arg(caseSensitivity(entry) == Qt::CaseInsensitive ? QLatin1String("[c]") - : QString()) + .arg(caseSensitivity(fp.filePath) == Qt::CaseInsensitive ? QLatin1String("[c]") + : QString()) .arg(quoted))); } BaseFileFilter::prepareSearch(entry);