Compare commits

...

2 Commits

Author SHA1 Message Date
0d01fa977d shared: LooqsQuery: Consider " a part of the loneword
Strictly speaking a hack, and we may probably need to
add more chars here.

This mainly fixes the difference between:

"one two"
and c:("one two")

In the first case they are "lonewords", the " does
not get picked up. Then, the search results are something
not expected.
2022-04-25 22:27:46 +02:00
b229d9a68d cli: CommandUpdate: Add missing clear of files vector 2022-04-25 22:22:40 +02:00
2 changed files with 2 additions and 1 deletions

View File

@ -108,6 +108,7 @@ int CommandUpdate::handle(QStringList arguments)
} }
} }
offset += limit; offset += limit;
files.clear();
processedRows = this->dbService->getFiles(files, pattern, offset, limit); processedRows = this->dbService->getFiles(files, pattern, offset, limit);
} }

View File

@ -177,7 +177,7 @@ LooqsQuery LooqsQuery::build(QString expression, TokenType loneWordsTokenType, b
QStringList loneWords; QStringList loneWords;
LooqsQuery result; LooqsQuery result;
QRegularExpression rx("((?<filtername>(\\.|\\w)+):(?<args>\\((?<innerargs>[^\\)]+)\\)|([\\w,])+)|(?<boolean>AND|OR)" QRegularExpression rx("((?<filtername>(\\.|\\w)+):(?<args>\\((?<innerargs>[^\\)]+)\\)|([\\w,])+)|(?<boolean>AND|OR)"
"|(?<negation>!)|(?<bracket>\\(|\\))|(?<loneword>\\w+))"); "|(?<negation>!)|(?<bracket>\\(|\\))|(?<loneword>[\"\\w]+))");
QRegularExpressionMatchIterator i = rx.globalMatch(expression); QRegularExpressionMatchIterator i = rx.globalMatch(expression);
auto previousWasBool = [&result] { return !result.tokens.empty() && ((result.tokens.last().type & BOOL) == BOOL); }; auto previousWasBool = [&result] { return !result.tokens.empty() && ((result.tokens.last().type & BOOL) == BOOL); };
auto previousWas = [&result](TokenType t) { return !result.tokens.empty() && (result.tokens.last().type == t); }; auto previousWas = [&result](TokenType t) { return !result.tokens.empty() && (result.tokens.last().type == t); };