From 9e0beb80469038fde0d0125e5cd51e6f0257766f Mon Sep 17 00:00:00 2001 From: "royqh1979@gmail.com" Date: Sun, 10 Oct 2021 20:20:43 +0800 Subject: [PATCH] - fix: code completion popup not show after '->' inputted --- NEWS.md | 3 +++ RedPandaIDE/editor.cpp | 16 +++++++++++----- 2 files changed, 14 insertions(+), 5 deletions(-) diff --git a/NEWS.md b/NEWS.md index ba11b084..2caa224c 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,3 +1,6 @@ +Version 0.6.4 + - fix: code completion popup not show after '->' inputted + Version 0.6.3 - fix: should use c++ syntax to check ".h" files - fix: can't copy contents in a readonly editor diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 9fb4fe4b..8b7305dc 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -703,10 +703,16 @@ void Editor::keyPressEvent(QKeyEvent *event) case '[': case ']': case '<': - case '>': case '*': handled = handleSymbolCompletion(ch); return; + case '>': + if ((caretX() <= 1) || lineText().isEmpty() + || lineText()[caretX() - 2] != '-') { + handled = handleSymbolCompletion(ch); + return; + } + break; } } @@ -1750,14 +1756,14 @@ bool Editor::handleCodeCompletion(QChar key) return true; case '>': setSelText(key); - if ((caretX() > 1) && (lineText().length() >= 1) && - (lineText()[caretX() - 2] == '-')) + if ((caretX() > 2) && (lineText().length() >= 2) && + (lineText()[caretX() - 3] == '-')) showCompletion(false); return true; case ':': setSelText(key); - if ((caretX() > 1) && (lineText().length() >= 1) && - (lineText()[caretX() - 2] == ':')) + if ((caretX() > 2) && (lineText().length() >= 2) && + (lineText()[caretX() - 3] == ':')) showCompletion(false); return true; case '/':