Revert "refactor: Move all processing logic to CodeHandler::processText()" (#109)

This commit is contained in:
Povilas Kanapickas 2025-03-07 02:57:13 +02:00 committed by GitHub
parent 521261e0a3
commit 90beebf2ee
No known key found for this signature in database
GPG Key ID: B5690EEEBB952194
4 changed files with 7 additions and 18 deletions

View File

@ -22,12 +22,8 @@
namespace QodeAssist { namespace QodeAssist {
QString CodeHandler::processText(QString text, bool smartProcess) QString CodeHandler::processText(QString text)
{ {
if (!smartProcess) {
return text;
}
QString result; QString result;
QStringList lines = text.split('\n'); QStringList lines = text.split('\n');
bool inCodeBlock = false; bool inCodeBlock = false;

View File

@ -28,7 +28,7 @@ namespace QodeAssist {
class CodeHandler class CodeHandler
{ {
public: public:
static QString processText(QString text, bool smartProcess = true); static QString processText(QString text);
static QString detectLanguage(const QString &line); static QString detectLanguage(const QString &line);

View File

@ -293,9 +293,11 @@ void LLMClientInterface::sendCompletionToClient(
LOG_MESSAGE(QString("Completions before filter: \n%1").arg(completion)); LOG_MESSAGE(QString("Completions before filter: \n%1").arg(completion));
bool smartProcess = promptTemplate->type() == LLMCore::TemplateType::Chat QString processedCompletion
&& Settings::codeCompletionSettings().smartProcessInstuctText(); = promptTemplate->type() == LLMCore::TemplateType::Chat
QString processedCompletion = CodeHandler::processText(completion, smartProcess); && Settings::codeCompletionSettings().smartProcessInstuctText()
? CodeHandler::processText(completion)
: completion;
completionItem[LanguageServerProtocol::textKey] = processedCompletion; completionItem[LanguageServerProtocol::textKey] = processedCompletion;
QJsonObject range; QJsonObject range;

View File

@ -33,15 +33,6 @@ class CodeHandlerTest : public QObject, public testing::Test
Q_OBJECT Q_OBJECT
}; };
TEST_F(CodeHandlerTest, testProcessTextNoProcessWithCodeBlock)
{
QString input = "This is a comment\n"
"```python\nprint('Hello, world!')\n```\n"
"Another comment";
EXPECT_EQ(CodeHandler::processText(input, false), input);
}
TEST_F(CodeHandlerTest, testProcessTextWithCodeBlock) TEST_F(CodeHandlerTest, testProcessTextWithCodeBlock)
{ {
QString input = "This is a comment\n" QString input = "This is a comment\n"