Commit 11da2fdc authored by Thiago Macieira's avatar Thiago Macieira Committed by Eike Ziller

Don't accept a column/line number selection just because of ":"

If you had typed "filename.cpp:142" in the Locator field, Creator
would offer "Column 142" the first option. At the very least, that's
confusing because the user intended to select line 142, not column --
for a while I thought someone had typed the wrong word in the source
code.

But even worse, this selection was the first entry, so instead of
jumping to filename.cpp on line 142, the user ended up still on the
same file and line, but on a different column.

Instead, simply validate that the parts before and after the colon are
actually numbers.

Change-Id: I1f1fbd33d702ae26c41fd2485aa99fae800e1410
Reviewed-by: default avatarEike Ziller <eike.ziller@digia.com>
parent 924115d7
......@@ -64,10 +64,13 @@ QList<FilterEntry> LineNumberFilter::matchesFor(QFutureInterface<Locator::Filter
int sectionCount = lineAndColumn.size();
int line = 0;
int column = 0;
bool ok;
if (sectionCount > 0)
line = lineAndColumn.at(0).toInt();
if (sectionCount > 1)
column = lineAndColumn.at(1).toInt();
line = lineAndColumn.at(0).toInt(&ok);
if (ok && sectionCount > 1)
column = lineAndColumn.at(1).toInt(&ok);
if (!ok)
return value;
if (currentTextEditor() && (line > 0 || column > 0)) {
LineColumn data;
data.first = line;
......
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