From ee26d9d0a05ce560589e84092cb6df0e56e0bb36 Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Wed, 23 Aug 2023 20:47:23 +0800 Subject: [PATCH] - fix: Symbol completion of '(' before selection may fail, if cursor is at the beginning of the selection. --- NEWS.md | 2 +- RedPandaIDE/editor.cpp | 21 ++++++++++++--------- 2 files changed, 13 insertions(+), 10 deletions(-) diff --git a/NEWS.md b/NEWS.md index cbeb8ec2..1ae87a39 100644 --- a/NEWS.md +++ b/NEWS.md @@ -1,6 +1,6 @@ Red Panda C++ Version 2.25 - - change: Symbol completion of '(' won't test current character at the cursor. + - fix: Symbol completion of '(' before selection may fail, if cursor is at the beginning of the selection. - change: Symbol completion of '{' won't insert extra new lines. Red Panda C++ Version 2.24 diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 6595a580..31c8c188 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -1017,17 +1017,20 @@ void Editor::keyPressEvent(QKeyEvent *event) case '*': case ';': case ',': - case '(': handled = handleSymbolCompletion(ch); return; -// QChar nextCh; -// if (selAvail()) { -// nextCh = nextNonSpaceChar(caretY()-1,caretX()-1); -// } else { -// nextCh = nextNonSpaceChar(caretY()-1,caretX()-1); -// } -// if (!isIdentChar(nextCh) && nextCh!='(' -// && nextCh!='"' && nextCh!='\'' ){ + case '(': { + if (!selAvail()) { + QChar nextCh = nextNonSpaceChar(caretY()-1,caretX()-1); + if (!isIdentChar(nextCh) && nextCh!='(' + && nextCh!='"' && nextCh!='\'' ){ + handled = handleSymbolCompletion(ch); + } + } else { + handled = handleSymbolCompletion(ch); + } + return; + } case '<': case '>': if (mParser) {