Commit 231aeafd authored by Eike Ziller's avatar Eike Ziller Committed by hjk
Browse files

Fix that locator filters weren't accepting column numbers

There was some adaption of locator filter code missing in
44e7eca5

 .
Also remove some duplication of logic.

Change-Id: I0a4b0920ea57472c922f1110b51b7eb8bad509b3
Reviewed-by: default avatarhjk <hjk@theqtcompany.com>
parent 447f42d0
......@@ -180,7 +180,7 @@ void EditorManagerPlaceHolder::currentModeChanged(IMode *mode)
static EditorManager *m_instance = 0;
static EditorManagerPrivate *d;
static int extractNumericSuffix(QString *fileName)
static int extractNumericSuffix(QString *fileName, QString *postfix = 0)
{
int i = fileName->length() - 1;
for (; i >= 0; --i) {
......@@ -195,6 +195,8 @@ static int extractNumericSuffix(QString *fileName)
const QString suffix = fileName->mid(i + 1);
const int result = suffix.toInt(&ok);
if (suffix.isEmpty() || ok) {
if (postfix)
*postfix = fileName->mid(i);
fileName->truncate(i);
return result;
}
......@@ -2552,25 +2554,15 @@ IEditor *EditorManager::openEditorAt(const QString &fileName, int line, int colu
fileName, line, column, editorId, flags, newEditor);
}
// Extract line number suffix. Return the suffix (e.g. ":132") and truncates the filename accordingly.
QString EditorManager::splitLineNumber(QString *fileName)
// Extract line and column number suffix. Return the suffix (e.g. ":132") and truncates the filename accordingly.
QString EditorManager::splitLineAndColumnNumber(QString *fileName)
{
int i = fileName->length() - 1;
for (; i >= 0; --i) {
if (!fileName->at(i).isNumber())
break;
}
if (i == -1)
return QString();
const QChar c = fileName->at(i);
if (c == QLatin1Char(':') || c == QLatin1Char('+')) {
const QString result = fileName->mid(i + 1);
bool ok;
result.toInt(&ok);
if (result.isEmpty() || ok) {
fileName->truncate(i);
return QString(c) + result;
}
QString postfix;
if (extractNumericSuffix(fileName, &postfix)) {
QString previousPostfix;
if (extractNumericSuffix(fileName, &previousPostfix))
postfix.prepend(previousPostfix);
return postfix;
}
return QString();
}
......
......@@ -109,7 +109,7 @@ public:
};
Q_DECLARE_FLAGS(OpenEditorFlags, OpenEditorFlag)
static QString splitLineNumber(QString *fileName);
static QString splitLineAndColumnNumber(QString *fileName);
static IEditor *openEditor(const QString &fileName, Id editorId = Id(),
OpenEditorFlags flags = NoFlags, bool *newEditor = 0);
static IEditor *openEditorAt(const QString &fileName, int line, int column = 0,
......
......@@ -103,7 +103,7 @@ QList<LocatorFilterEntry> BaseFileFilter::matchesFor(QFutureInterface<LocatorFil
QList<LocatorFilterEntry> betterEntries;
QList<LocatorFilterEntry> goodEntries;
QString needle = trimWildcards(QDir::fromNativeSeparators(origEntry));
const QString lineNoSuffix = EditorManager::splitLineNumber(&needle);
const QString lineNoSuffix = EditorManager::splitLineAndColumnNumber(&needle);
QStringMatcher matcher(needle, Qt::CaseInsensitive);
const QChar asterisk = QLatin1Char('*');
QRegExp regexp(asterisk + needle+ asterisk, Qt::CaseInsensitive, QRegExp::Wildcard);
......
......@@ -119,7 +119,7 @@ QList<LocatorFilterEntry> FileSystemFilter::matchesFor(QFutureInterface<LocatorF
}
// file names can match with +linenumber or :linenumber
name = entry;
const QString lineNoSuffix = EditorManager::splitLineNumber(&name);
const QString lineNoSuffix = EditorManager::splitLineAndColumnNumber(&name);
name = QFileInfo(name).fileName();
foreach (const QString &file, files) {
if (future.isCanceled())
......
......@@ -64,7 +64,7 @@ QList<LocatorFilterEntry> OpenDocumentsFilter::matchesFor(QFutureInterface<Locat
QList<LocatorFilterEntry> goodEntries;
QList<LocatorFilterEntry> betterEntries;
QString entry = entry_;
const QString lineNoSuffix = EditorManager::splitLineNumber(&entry);
const QString lineNoSuffix = EditorManager::splitLineAndColumnNumber(&entry);
const QChar asterisk = QLatin1Char('*');
QString pattern = QString(asterisk);
pattern += entry;
......
Markdown is supported
0% or .
You are about to add 0 people to the discussion. Proceed with caution.
Finish editing this message first!
Please register or to comment