diff options
author | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2017-07-14 12:38:06 +0200 |
---|---|---|
committer | Nikolai Kosjar <nikolai.kosjar@qt.io> | 2017-07-17 07:58:24 +0000 |
commit | be3e12c8aff85e133f7a3cddb1c0a9ecf8607467 (patch) | |
tree | 9d90196d9cce66db6bbf39c9f5291fa1dfc77687 /src/libs/cplusplus/MatchingText.cpp | |
parent | be2b3c91ae4ddb97c35237da11b350c99cc6fd3b (diff) | |
download | qt-creator-be3e12c8aff85e133f7a3cddb1c0a9ecf8607467.tar.gz |
CppEditor: Avoid auto insertion of '}' in empty line
...when typing '{'.
Change-Id: Ia1d3bcd7440c96ed3c8c1479148dd74d3d291689
Reviewed-by: David Schulz <david.schulz@qt.io>
Diffstat (limited to 'src/libs/cplusplus/MatchingText.cpp')
-rw-r--r-- | src/libs/cplusplus/MatchingText.cpp | 6 |
1 files changed, 5 insertions, 1 deletions
diff --git a/src/libs/cplusplus/MatchingText.cpp b/src/libs/cplusplus/MatchingText.cpp index f783d4c508..3fdb573b91 100644 --- a/src/libs/cplusplus/MatchingText.cpp +++ b/src/libs/cplusplus/MatchingText.cpp @@ -143,9 +143,13 @@ bool MatchingText::contextAllowsAutoParentheses(const QTextCursor &cursor, if (!textToInsert.isEmpty()) ch = textToInsert.at(0); + if (ch == QLatin1Char('{') && cursor.block().text().trimmed().isEmpty()) + return false; // User just might want to wrap up some lines. + if (!shouldInsertMatchingText(cursor) && ch != QLatin1Char('\'') && ch != QLatin1Char('"')) return false; - else if (isInCommentHelper(cursor)) + + if (isInCommentHelper(cursor)) return false; return true; |