forked from qt-creator/qt-creator
C++: Do not insert matching } within string
Regression from
commit a6aa287720
C++: Fine-tune auto insertion of '}'
Change-Id: I3ede8c7a1e3c73708d5d5a59c314e4b4596976b2
Reviewed-by: Ivan Donchevskii <ivan.donchevskii@qt.io>
Reviewed-by: Christian Stenger <christian.stenger@qt.io>
This commit is contained in:
@@ -326,6 +326,11 @@ static bool allowAutoClosingBrace(const QTextCursor &cursor,
|
|||||||
|
|
||||||
int prevState;
|
int prevState;
|
||||||
const Tokens tokens = getTokens(cursor, prevState);
|
const Tokens tokens = getTokens(cursor, prevState);
|
||||||
|
|
||||||
|
const Token token = tokenAtPosition(tokens, cursor.positionInBlock());
|
||||||
|
if (token.isStringLiteral())
|
||||||
|
return false;
|
||||||
|
|
||||||
if (isAfterNamespaceDefinition(tokens, cursor.positionInBlock()))
|
if (isAfterNamespaceDefinition(tokens, cursor.positionInBlock()))
|
||||||
return false;
|
return false;
|
||||||
|
|
||||||
|
|||||||
@@ -256,4 +256,11 @@ TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotBeforeNestedName
|
|||||||
ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
|
ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
|
||||||
}
|
}
|
||||||
|
|
||||||
|
TEST_F(MatchingText, ContextAllowsAutoParentheses_CurlyBrace_NotWithinString)
|
||||||
|
{
|
||||||
|
const Document document("\"a@b\"");
|
||||||
|
|
||||||
|
ASSERT_FALSE(MT::contextAllowsAutoParentheses(document.cursor, "{"));
|
||||||
|
}
|
||||||
|
|
||||||
} // anonymous
|
} // anonymous
|
||||||
|
|||||||
Reference in New Issue
Block a user