fix #313 : Caret on '(' / ',' in string/comment/char may invoke function tips.

This commit is contained in:
Roy Qu 2024-03-24 18:27:40 +08:00
parent 496cfd1337
commit 730bed9587
1 changed files with 16 additions and 8 deletions

View File

@ -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
&& start+token.length()>=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)