From ffe78f9c626ddb8d661930f911e8c1622cddfabb Mon Sep 17 00:00:00 2001 From: "Danilo M." Date: Mon, 3 Aug 2026 20:41:21 +0200 Subject: 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. --- src/querycompleter.cpp | 18 ++++++++++++++---- 1 file changed, 14 insertions(+), 4 deletions(-) (limited to 'src/querycompleter.cpp') 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; } -- cgit v1.2.3