forked from qt-creator/qt-creator
tune auto-parentheses
do not close braces automatically on enter if the next line's indentation is deeper than the current line's
This commit is contained in:
@@ -1537,7 +1537,25 @@ int CPPEditor::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor)
|
||||
else
|
||||
braceDepth= 0;
|
||||
|
||||
if (braceDepth > 0) { // we do have an extra brace, let's close it
|
||||
if (braceDepth <= 0)
|
||||
return 0; // braces are all balanced or worse, no need to do anything
|
||||
|
||||
// we have an extra brace , let's see if we should close it
|
||||
|
||||
|
||||
/* verify that the next block is not further intended compared to the current block.
|
||||
This covers the following case:
|
||||
|
||||
if (condition) {|
|
||||
statement;
|
||||
*/
|
||||
const TabSettings &ts = tabSettings();
|
||||
QTextBlock block = cursor.block();
|
||||
int indentation = ts.indentationColumn(block.text());
|
||||
if (block.next().isValid()
|
||||
&& ts.indentationColumn(block.next().text()) > indentation)
|
||||
return 0;
|
||||
|
||||
int pos = cursor.position();
|
||||
|
||||
MatchingText matchingText;
|
||||
@@ -1545,7 +1563,6 @@ int CPPEditor::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor)
|
||||
|
||||
cursor.insertText(textToInsert);
|
||||
cursor.setPosition(pos);
|
||||
const TabSettings &ts = tabSettings();
|
||||
if (ts.m_autoIndent) {
|
||||
cursor.insertBlock();
|
||||
indent(document(), cursor, QChar::Null);
|
||||
@@ -1557,8 +1574,6 @@ int CPPEditor::paragraphSeparatorAboutToBeInserted(QTextCursor &cursor)
|
||||
cursor.setPosition(pos);
|
||||
m_allowSkippingOfBlockEnd = true;
|
||||
return 1;
|
||||
}
|
||||
return 0;
|
||||
}
|
||||
|
||||
bool CPPEditor::contextAllowsAutoParentheses(const QTextCursor &cursor,
|
||||
|
||||
Reference in New Issue
Block a user