aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorDanilo M. <danix@danix.xyz>2026-08-03 20:41:21 +0200
committerDanilo M. <danix@danix.xyz>2026-08-04 12:54:04 +0200
commitffe78f9c626ddb8d661930f911e8c1622cddfabb (patch)
tree2412840f58cc407592e68fe1324e16372b1d7fa1 /src
parentba3931bc84fc046484949a99b3d8d2562f4ca2b2 (diff)
downloadqtmaildir-ffe78f9c626ddb8d661930f911e8c1622cddfabb.tar.gz
qtmaildir-ffe78f9c626ddb8d661930f911e8c1622cddfabb.zip
feat(completion): recognise value context after a prefix
The replace span covers the value only, so accepting a completion never overwrites the prefix that selected it.
Diffstat (limited to 'src')
-rw-r--r--src/querycompleter.cpp18
1 files changed, 14 insertions, 4 deletions
diff --git a/src/querycompleter.cpp b/src/querycompleter.cpp
index 44ca010..1e86c1b 100644
--- a/src/querycompleter.cpp
+++ b/src/querycompleter.cpp
@@ -46,9 +46,19 @@ CompletionContext completionContext(const QString &text, int cursor)
const int start = tokenStart(text, cursor);
const QString token = text.mid(start, cursor - start);
- ctx.kind = CompletionContext::Prefix;
- ctx.stem = token;
- ctx.replaceFrom = start;
- ctx.replaceLength = token.size();
+ const int colon = token.indexOf(QLatin1Char(':'));
+ if (colon < 0) {
+ ctx.kind = CompletionContext::Prefix;
+ ctx.stem = token;
+ ctx.replaceFrom = start;
+ ctx.replaceLength = token.size();
+ return ctx;
+ }
+
+ ctx.kind = CompletionContext::Value;
+ ctx.prefix = token.left(colon).toLower();
+ ctx.stem = token.mid(colon + 1);
+ ctx.replaceFrom = start + colon + 1;
+ ctx.replaceLength = ctx.stem.size();
return ctx;
}