From 3d2fb5338865a22329cb0ce6157082c515fe1fff Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Wed, 10 Nov 2021 21:28:08 +0800 Subject: [PATCH] - fix: can't show code completion popup if symbol is proceed with an operator '~' ( and it's not a destructor) - fix: can't show code completion popup when define MACRO - fix: can't debug files with chinese characters in the path --- NEWS.md | 3 +++ RedPandaIDE/debugger.cpp | 6 +++--- RedPandaIDE/editor.cpp | 3 +-- RedPandaIDE/mainwindow.cpp | 1 - RedPandaIDE/mainwindow.ui | 8 ++++---- RedPandaIDE/widgets/codecompletionpopup.cpp | 12 ++++++++++++ 6 files changed, 23 insertions(+), 10 deletions(-) diff --git a/NEWS.md b/NEWS.md index 33530898..90a09e4e 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,9 @@ Version 0.8.4 For Dev-C++ 7 Beta - enhancement: auto save/load the default open folder in the configuration file - fix: shouldn't auto add '()' when char succeeding the completed function name is '(' + - fix: can't show code completion popup if symbol is proceed with an operator '~' ( and it's not a destructor) + - fix: can't show code completion popup when define MACRO + - fix: can't debug files with chinese characters in the path Version 0.8.3 For Dev-C++ 7 Beta - enhancement: View menu diff --git a/RedPandaIDE/debugger.cpp b/RedPandaIDE/debugger.cpp index 0fca8bd3..8ac29c10 100644 --- a/RedPandaIDE/debugger.cpp +++ b/RedPandaIDE/debugger.cpp @@ -1450,9 +1450,9 @@ void DebugReader::runNextCmd() emit cmdStarted(); QByteArray s; - s=pCmd->command.toUtf8(); + s=pCmd->command.toLocal8Bit(); if (!pCmd->params.isEmpty()) { - s+=' '+pCmd->params.toUtf8(); + s+= ' '+pCmd->params.toLocal8Bit(); } s+= "\n"; if (mProcess->write(s)<0) { @@ -1681,7 +1681,7 @@ void DebugReader::run() readed = mProcess->readAll(); buffer += readed; if (getLastAnnotation(buffer) == AnnotationType::TPrompt) { - mOutput = QString::fromUtf8(buffer); + mOutput = QString::fromLocal8Bit(buffer); processDebugOutput(); buffer.clear(); mCmdRunning = false; diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index fb34914f..33866062 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -2279,8 +2279,7 @@ void Editor::showCompletion(bool autoComplete) if (tokenType == SynHighlighterTokenType::PreprocessDirective) {//Preprocessor word = getWordAtPosition(this,caretXY(),pBeginPos,pEndPos, WordPurpose::wpDirective); if (!word.startsWith('#')) { - //showTabnineCompletion(); - return; + word = ""; } } else if (tokenType == SynHighlighterTokenType::Comment) { //Comment, javadoc tag word = getWordAtPosition(this,caretXY(),pBeginPos,pEndPos, WordPurpose::wpJavadoc); diff --git a/RedPandaIDE/mainwindow.cpp b/RedPandaIDE/mainwindow.cpp index c8d2c8ef..396f7314 100644 --- a/RedPandaIDE/mainwindow.cpp +++ b/RedPandaIDE/mainwindow.cpp @@ -1296,7 +1296,6 @@ void MainWindow::debug() if (!mDebugger->start()) return; filePath.replace('\\','/'); - mDebugger->sendCommand("set","host charset UTF-8"); mDebugger->sendCommand("file", '"' + filePath + '"'); if (mProject->options().type == ProjectType::DynamicLib) { diff --git a/RedPandaIDE/mainwindow.ui b/RedPandaIDE/mainwindow.ui index 4a8c0f8a..507115f3 100644 --- a/RedPandaIDE/mainwindow.ui +++ b/RedPandaIDE/mainwindow.ui @@ -85,7 +85,7 @@ QTabWidget::West - 0 + 1 true @@ -171,10 +171,10 @@ Qt::ElideNone - true - - false + + + 50 diff --git a/RedPandaIDE/widgets/codecompletionpopup.cpp b/RedPandaIDE/widgets/codecompletionpopup.cpp index b5587591..9bc19456 100644 --- a/RedPandaIDE/widgets/codecompletionpopup.cpp +++ b/RedPandaIDE/widgets/codecompletionpopup.cpp @@ -72,6 +72,11 @@ void CodeCompletionPopup::prepareSearch(const QString &phrase, const QString &fi mIncludedFiles = mParser->getFileIncludes(filename); getCompletionFor(filename,phrase,line); + if (mFullCompletionStatementList.isEmpty() && phrase.startsWith('~')) { + mPhrase = phrase.mid(1); + getCompletionFor(filename,mPhrase,line); + } + //todo: notify model //CodeComplForm.lbCompletion.Font.Size := FontSize; //CodeComplForm.lbCompletion.ItemHeight := CodeComplForm.lbCompletion.Canvas.TextHeight('F')+6; @@ -110,6 +115,13 @@ bool CodeCompletionPopup::search(const QString &phrase, bool autoHideOnSingleRes QString symbol = phrase.mid(i); // filter fFullCompletionStatementList to fCompletionStatementList filterList(symbol); + + //if can't find a destructor, maybe '~' is only an operator + if (mCompletionStatementList.isEmpty() && phrase.startsWith('~')) { + symbol = phrase.mid(1); + filterList(symbol); + } + mModel->notifyUpdated(); setCursor(oldCursor);