From 142761d86fe994f5b44075a3ac4a4ef02af0300a Mon Sep 17 00:00:00 2001 From: nightwing Date: Tue, 7 Jan 2014 23:03:32 +0400 Subject: [PATCH] fix regression in { pairing --- lib/ace/mode/behaviour/cstyle.js | 23 ++++++++++++++--------- 1 file changed, 14 insertions(+), 9 deletions(-) diff --git a/lib/ace/mode/behaviour/cstyle.js b/lib/ace/mode/behaviour/cstyle.js index 2c831667..5bdd997c 100644 --- a/lib/ace/mode/behaviour/cstyle.js +++ b/lib/ace/mode/behaviour/cstyle.js @@ -132,7 +132,7 @@ var CstyleBehaviour = function () { selection: false }; } else if (CstyleBehaviour.isSaneInsertion(editor, session)) { - if (/[\]\}\)]/.test(line[cursor.column])) { + if (/[\]\}\)]/.test(line[cursor.column]) || editor.inMultiSelectMode) { CstyleBehaviour.recordAutoInsert(editor, session, "}"); return { text: '{}', @@ -165,19 +165,24 @@ var CstyleBehaviour = function () { CstyleBehaviour.clearMaybeInsertedClosing(); } 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}, '}'); if (!openBracePos) return null; - - var indent = this.getNextLineIndent(state, line.substring(0, cursor.column), session.getTabString()); + var next_indent = this.$getIndent(session.getLine(openBracePos.row)); + } else if (closing) { var next_indent = this.$getIndent(line); - - return { - text: '\n' + indent + '\n' + next_indent + closing, - selection: [1, indent.length, 1, indent.length] - }; + } else { + return; } + var indent = next_indent + session.getTabString(); + + return { + text: '\n' + indent + '\n' + next_indent + closing, + selection: [1, indent.length, 1, indent.length] + }; + } else { + CstyleBehaviour.clearMaybeInsertedClosing(); } });