mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-07-20 22:14:42 -04:00
fix: Improve support for code blocks without language (#108)
This makes it possible to represent code blocks in models that emit their suggestion immediately after the ``` characters.
This commit is contained in:
committed by
GitHub
parent
9a5047618d
commit
f94c79a5ff
@ -37,6 +37,14 @@
|
||||
|
||||
namespace QodeAssist {
|
||||
|
||||
QString extractFilePathFromRequest(const QJsonObject &request)
|
||||
{
|
||||
QJsonObject params = request["params"].toObject();
|
||||
QJsonObject doc = params["doc"].toObject();
|
||||
QString uri = doc["uri"].toString();
|
||||
return QUrl(uri).toLocalFile();
|
||||
}
|
||||
|
||||
LLMClientInterface::LLMClientInterface()
|
||||
: m_requestHandler(this)
|
||||
{
|
||||
@ -251,9 +259,8 @@ LLMCore::ContextData LLMClientInterface::prepareContext(
|
||||
QJsonObject params = request["params"].toObject();
|
||||
QJsonObject doc = params["doc"].toObject();
|
||||
QJsonObject position = doc["position"].toObject();
|
||||
QString uri = doc["uri"].toString();
|
||||
|
||||
Utils::FilePath filePath = Utils::FilePath::fromString(QUrl(uri).toLocalFile());
|
||||
Utils::FilePath filePath = Utils::FilePath::fromString(extractFilePathFromRequest(request));
|
||||
TextEditor::TextDocument *textDocument = TextEditor::TextDocument::textDocumentForFilePath(
|
||||
filePath);
|
||||
|
||||
@ -296,7 +303,7 @@ void LLMClientInterface::sendCompletionToClient(
|
||||
QString processedCompletion
|
||||
= promptTemplate->type() == LLMCore::TemplateType::Chat
|
||||
&& Settings::codeCompletionSettings().smartProcessInstuctText()
|
||||
? CodeHandler::processText(completion)
|
||||
? CodeHandler::processText(completion, extractFilePathFromRequest(request))
|
||||
: completion;
|
||||
|
||||
completionItem[LanguageServerProtocol::textKey] = processedCompletion;
|
||||
|
Reference in New Issue
Block a user