From 730bed958788fcacddbee7e976c57db2270641ac Mon Sep 17 00:00:00 2001 From: Roy Qu Date: Sun, 24 Mar 2024 18:27:40 +0800 Subject: [PATCH] fix #313 : Caret on '(' / ',' in string/comment/char may invoke function tips. --- RedPandaIDE/editor.cpp | 24 ++++++++++++++++-------- 1 file changed, 16 insertions(+), 8 deletions(-) diff --git a/RedPandaIDE/editor.cpp b/RedPandaIDE/editor.cpp index 1856f785..5035e9be 100644 --- a/RedPandaIDE/editor.cpp +++ b/RedPandaIDE/editor.cpp @@ -4203,10 +4203,25 @@ void Editor::updateFunctionTip(bool showTip) int currentParamPos = 1; if (currentLine>=document()->count()) return; + QChar ch=lastNonSpaceChar(currentLine,currentChar); if (ch!="(" && ch!=",") return; + QSynedit::PTokenAttribute attr; + QString token; + QSynedit::SyntaxState syntaxState; + QSynedit::BufferCoord pos = caretPos; + pos.ch--; + if (getTokenAttriAtRowCol(pos, token, attr, syntaxState)) { + if (syntaxer()->isStringNotFinished(syntaxState.state)) + return; + if (syntaxer()->isCommentNotFinished(syntaxState.state)) + return; + if (attr->tokenType() == QSynedit::TokenType::Character) + return; + } + while (currentLine>=0) { QString line = document()->getLine(currentLine); if (currentLine!=caretPos.line-1) @@ -4225,14 +4240,7 @@ 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 (attr->tokenType() == QSynedit::TokenType::String)