mirror of
https://github.com/Palm1r/QodeAssist.git
synced 2025-05-28 03:10:28 -04:00
Revert "refactor: Move all processing logic to CodeHandler::processText()" (#109)
This commit is contained in:
parent
521261e0a3
commit
90beebf2ee
@ -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;
|
||||||
|
@ -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);
|
||||||
|
|
||||||
|
@ -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;
|
||||||
|
@ -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"
|
||||||
|
Loading…
Reference in New Issue
Block a user