Make sure wrapping behaves the same as before

This commit is contained in:
Lennart Kats 2012-10-22 14:17:08 +02:00
commit 72dde40c76

View file

@ -88,8 +88,6 @@ var CstyleBehaviour = function () {
this.add("braces", "insertion", function (state, action, editor, session, text) { this.add("braces", "insertion", function (state, action, editor, session, text) {
if (text == '{') { if (text == '{') {
if (!CstyleBehaviour.isSaneInsertion(editor, session))
return;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "" && selected !== "{") { if (selected !== "" && selected !== "{") {
@ -97,7 +95,7 @@ var CstyleBehaviour = function () {
text: '{' + selected + '}', text: '{' + selected + '}',
selection: false selection: false
}; };
} else { } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
CstyleBehaviour.recordAutoInsert(editor, session, "}"); CstyleBehaviour.recordAutoInsert(editor, session, "}");
return { return {
text: '{}', text: '{}',
@ -152,8 +150,6 @@ var CstyleBehaviour = function () {
this.add("parens", "insertion", function (state, action, editor, session, text) { this.add("parens", "insertion", function (state, action, editor, session, text) {
if (text == '(') { if (text == '(') {
if (!CstyleBehaviour.isSaneInsertion(editor, session))
return;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
@ -161,7 +157,7 @@ var CstyleBehaviour = function () {
text: '(' + selected + ')', text: '(' + selected + ')',
selection: false selection: false
}; };
} else { } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
CstyleBehaviour.recordAutoInsert(editor, session, ")"); CstyleBehaviour.recordAutoInsert(editor, session, ")");
return { return {
text: '()', text: '()',
@ -199,8 +195,6 @@ var CstyleBehaviour = function () {
this.add("brackets", "insertion", function (state, action, editor, session, text) { this.add("brackets", "insertion", function (state, action, editor, session, text) {
if (text == '[') { if (text == '[') {
if (!CstyleBehaviour.isSaneInsertion(editor, session))
return;
var selection = editor.getSelectionRange(); var selection = editor.getSelectionRange();
var selected = session.doc.getTextRange(selection); var selected = session.doc.getTextRange(selection);
if (selected !== "") { if (selected !== "") {
@ -208,7 +202,7 @@ var CstyleBehaviour = function () {
text: '[' + selected + ']', text: '[' + selected + ']',
selection: false selection: false
}; };
} else { } else if (CstyleBehaviour.isSaneInsertion(editor, session)) {
CstyleBehaviour.recordAutoInsert(editor, session, "]"); CstyleBehaviour.recordAutoInsert(editor, session, "]");
return { return {
text: '[]', text: '[]',