diff --git a/NEWS.md b/NEWS.md index a35d5e43..bae2c041 100644 --- a/NEWS.md +++ b/NEWS.md @@ -79,6 +79,8 @@ Red Panda C++ Version 2.27 - enhancement: Improve lambda expression support. - enhancement: Show type completion hint after "constexpr"/"extern"/"static"/"consteval"/"constinit"/"const"/"volatile"/"inline" etc. - enhancement: Restore line position after file is modified outside and reloaded. + - fix: Caret on '('/',' in string/comment shouldn't invoke function info tips. + - fix: Function name not correctly found if it and the '(' is not in one line; Red Panda C++ Version 2.26 - enhancement: Code suggestion for embedded std::vectors. diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 61f0b8b3..1856f785 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -4225,22 +4225,20 @@ void Editor::updateFunctionTip(bool showTip) QSynedit::PTokenAttribute attr = syntaxer()->getTokenAttribute(); if (start>=currentChar) break; - + if ( + (attr->tokenType() == QSynedit::TokenType::Comment + || attr->tokenType() == QSynedit::TokenType::String + ) + && currentLine == caretPos.line-1 && start=caretPos.ch-1) { + return; // in comment/string, do nothing + } if (attr->tokenType() != QSynedit::TokenType::Comment && attr->tokenType() != QSynedit::TokenType::Space) { - if (foundFunctionStart) { - if (attr!=syntaxer()->identifierAttribute()) - return; // not a function - functionNamePos.line = currentLine+1; - functionNamePos.ch = start+1; - break; - } + if (attr->tokenType() == QSynedit::TokenType::String) + token="\"\""; tokens.append(token); positions.append(start); - } else if (attr->tokenType() == QSynedit::TokenType::Comment - && currentLine == caretPos.line-1 && start=caretPos.ch) { - return; // in comment, do nothing } syntaxer()->next(); } @@ -4293,6 +4291,18 @@ void Editor::updateFunctionTip(bool showTip) } } } + } else { + int i = tokens.length()-1; + if (i>=0){ + if (!tokens[i].isEmpty() && + isIdentStartChar(tokens[i].front())) { + functionNamePos.line = currentLine+1; + functionNamePos.ch = positions[i]+1; + break; + } + // not a valid function + return; + } } if (functionNamePos.ch>=0) break;