feat: Improve code suggestions (#256)

This commit is contained in:
Petr Mironychev
2025-11-14 17:02:43 +01:00
committed by GitHub
parent 0ca1decd97
commit 9ecd285d1d
5 changed files with 276 additions and 46 deletions

View File

@ -418,12 +418,20 @@ void LLMClientInterface::sendCompletionToClient(
: completion;
}
if (processedCompletion.endsWith('\n')) {
QString withoutTrailing = processedCompletion.chopped(1);
if (!withoutTrailing.contains('\n')) {
LOG_MESSAGE(QString("Removed trailing newline from single-line completion"));
processedCompletion = withoutTrailing;
}
}
completionItem[LanguageServerProtocol::textKey] = processedCompletion;
QJsonObject range;
range["start"] = position;
QJsonObject end = position;
end["character"] = position["character"].toInt() + processedCompletion.length();
range["end"] = end;
range["end"] = position;
completionItem[LanguageServerProtocol::rangeKey] = range;
completionItem[LanguageServerProtocol::positionKey] = position;
completions.append(completionItem);