package
This commit is contained in:
parent
cbd29bc541
commit
d386d4c6a1
125 changed files with 3861 additions and 3761 deletions
|
|
@ -391,12 +391,12 @@ var CstyleBehaviour = function () {
|
|||
return {
|
||||
text: '{' + selected + '}',
|
||||
selection: false
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
text: '{}',
|
||||
selection: [1, 1]
|
||||
}
|
||||
};
|
||||
}
|
||||
} else if (text == '}') {
|
||||
var cursor = editor.getCursorPosition();
|
||||
|
|
@ -408,7 +408,7 @@ var CstyleBehaviour = function () {
|
|||
return {
|
||||
text: '',
|
||||
selection: [1, 1]
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
} else if (text == "\n") {
|
||||
|
|
@ -426,7 +426,7 @@ var CstyleBehaviour = function () {
|
|||
return {
|
||||
text: '\n' + indent + '\n' + next_indent,
|
||||
selection: [1, indent.length, 1, indent.length]
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
});
|
||||
|
|
@ -451,12 +451,12 @@ var CstyleBehaviour = function () {
|
|||
return {
|
||||
text: '(' + selected + ')',
|
||||
selection: false
|
||||
}
|
||||
};
|
||||
} else {
|
||||
return {
|
||||
text: '()',
|
||||
selection: [1, 1]
|
||||
}
|
||||
};
|
||||
}
|
||||
} else if (text == ')') {
|
||||
var cursor = editor.getCursorPosition();
|
||||
|
|
@ -468,7 +468,7 @@ var CstyleBehaviour = function () {
|
|||
return {
|
||||
text: '',
|
||||
selection: [1, 1]
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -487,14 +487,15 @@ var CstyleBehaviour = function () {
|
|||
});
|
||||
|
||||
this.add("string_dquotes", "insertion", function (state, action, editor, session, text) {
|
||||
if (text == '"') {
|
||||
if (text == '"' || text == "'") {
|
||||
var quote = text;
|
||||
var selection = editor.getSelectionRange();
|
||||
var selected = session.doc.getTextRange(selection);
|
||||
if (selected !== "") {
|
||||
return {
|
||||
text: '"' + selected + '"',
|
||||
text: quote + selected + quote,
|
||||
selection: false
|
||||
}
|
||||
};
|
||||
} else {
|
||||
var cursor = editor.getCursorPosition();
|
||||
var line = session.doc.getLine(cursor.row);
|
||||
|
|
@ -515,7 +516,7 @@ var CstyleBehaviour = function () {
|
|||
if (token.type == "string") {
|
||||
quotepos = -1;
|
||||
} else if (quotepos < 0) {
|
||||
quotepos = token.value.indexOf('"');
|
||||
quotepos = token.value.indexOf(quote);
|
||||
}
|
||||
if ((token.value.length + col) > selection.start.column) {
|
||||
break;
|
||||
|
|
@ -524,19 +525,19 @@ var CstyleBehaviour = function () {
|
|||
}
|
||||
|
||||
// Try and be smart about when we auto insert.
|
||||
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf('"') === token.value.length-1)))) {
|
||||
if (!token || (quotepos < 0 && token.type !== "comment" && (token.type !== "string" || ((selection.start.column !== token.value.length+col-1) && token.value.lastIndexOf(quote) === token.value.length-1)))) {
|
||||
return {
|
||||
text: '""',
|
||||
text: quote + quote,
|
||||
selection: [1,1]
|
||||
}
|
||||
};
|
||||
} else if (token && token.type === "string") {
|
||||
// Ignore input and move right one if we're typing over the closing quote.
|
||||
var rightChar = line.substring(cursor.column, cursor.column + 1);
|
||||
if (rightChar == '"') {
|
||||
if (rightChar == quote) {
|
||||
return {
|
||||
text: '',
|
||||
selection: [1, 1]
|
||||
}
|
||||
};
|
||||
}
|
||||
}
|
||||
}
|
||||
|
|
@ -545,7 +546,7 @@ var CstyleBehaviour = function () {
|
|||
|
||||
this.add("string_dquotes", "deletion", function (state, action, editor, session, range) {
|
||||
var selected = session.doc.getTextRange(range);
|
||||
if (!range.isMultiLine() && selected == '"') {
|
||||
if (!range.isMultiLine() && (selected == '"' || selected == "'")) {
|
||||
var line = session.doc.getLine(range.start.row);
|
||||
var rightChar = line.substring(range.start.column + 1, range.start.column + 2);
|
||||
if (rightChar == '"') {
|
||||
|
|
@ -555,7 +556,8 @@ var CstyleBehaviour = function () {
|
|||
}
|
||||
});
|
||||
|
||||
}
|
||||
};
|
||||
|
||||
oop.inherits(CstyleBehaviour, Behaviour);
|
||||
|
||||
exports.CstyleBehaviour = CstyleBehaviour;
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue