diff options
author | Eike Ziller <eike.ziller@qt.io> | 2018-08-20 13:01:32 +0200 |
---|---|---|
committer | Eike Ziller <eike.ziller@qt.io> | 2018-09-03 12:30:11 +0000 |
commit | e40b250d13b80fe2fed66b20266deafb14ac5df1 (patch) | |
tree | 4978dbc917e2045d3c650fa45bc1f1325a6d18bf | |
parent | 7a739b3b32faec78a84ba99dd2cda6aacb9a1ded (diff) |
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 <david.schulz@qt.io>
-rw-r--r-- | src/plugins/coreplugin/locator/spotlightlocatorfilter.mm | 12 |
1 files changed, 7 insertions, 5 deletions
diff --git a/src/plugins/coreplugin/locator/spotlightlocatorfilter.mm b/src/plugins/coreplugin/locator/spotlightlocatorfilter.mm index 12794d780f..f8cdd8189e 100644 --- a/src/plugins/coreplugin/locator/spotlightlocatorfilter.mm +++ b/src/plugins/coreplugin/locator/spotlightlocatorfilter.mm @@ -25,6 +25,7 @@ #include "spotlightlocatorfilter.h" +#include <coreplugin/editormanager/editormanager.h> #include <utils/qtcassert.h> #include <QMutex> @@ -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); |