fix regression in { pairing
This commit is contained in:
parent
30a4d12eb7
commit
142761d86f
1 changed files with 14 additions and 9 deletions
|
|
@ -132,7 +132,7 @@ var CstyleBehaviour = function () {
|
||||||
selection: false
|
selection: false
|
||||||
};
|
};
|
||||||
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
|
} else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
|
||||||
if (/[\]\}\)]/.test(line[cursor.column])) {
|
if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) {
|
||||||
CstyleBehaviour.recordAutoInsert(editor, session, "}");
|
CstyleBehaviour.recordAutoInsert(editor, session, "}");
|
||||||
return {
|
return {
|
||||||
text: '{}',
|
text: '{}',
|
||||||
|
|
@ -165,19 +165,24 @@ var CstyleBehaviour = function () {
|
||||||
CstyleBehaviour.clearMaybeInsertedClosing();
|
CstyleBehaviour.clearMaybeInsertedClosing();
|
||||||
}
|
}
|
||||||
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
||||||
if (rightChar == '}' || closing !== "") {
|
if (rightChar === '}') {
|
||||||
var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
|
var openBracePos = session.findMatchingBracket({row: cursor.row, column: cursor.column+1}, '}');
|
||||||
if (!openBracePos)
|
if (!openBracePos)
|
||||||
return null;
|
return null;
|
||||||
|
var next_indent = this.$getIndent(session.getLine(openBracePos.row));
|
||||||
var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString());
|
} else if (closing) {
|
||||||
var next_indent = this.$getIndent(line);
|
var next_indent = this.$getIndent(line);
|
||||||
|
} else {
|
||||||
return {
|
return;
|
||||||
text: '\n' + indent + '\n' + next_indent + closing,
|
|
||||||
selection: [1, indent.length, 1, indent.length]
|
|
||||||
};
|
|
||||||
}
|
}
|
||||||
|
var indent = next_indent + session.getTabString();
|
||||||
|
|
||||||
|
return {
|
||||||
|
text: '\n' + indent + '\n' + next_indent + closing,
|
||||||
|
selection: [1, indent.length, 1, indent.length]
|
||||||
|
};
|
||||||
|
} else {
|
||||||
|
CstyleBehaviour.clearMaybeInsertedClosing();
|
||||||
}
|
}
|
||||||
});
|
});
|
||||||
|
|
||||||
|
|
|
||||||
Loading…
Add table
Add a link
Reference in a new issue