fix weird pairing of quotes in cstyle behavior
This commit is contained in:
parent
2d06dc6316
commit
c356c14940
2 changed files with 18 additions and 4 deletions
|
|
@ -30,6 +30,7 @@
|
|||
|
||||
if (typeof process !== "undefined") {
|
||||
require("amd-loader");
|
||||
require("../../test/mockdom");
|
||||
}
|
||||
|
||||
define(function(require, exports, module) {
|
||||
|
|
@ -117,9 +118,9 @@ module.exports = {
|
|||
|
||||
editor.setValue("");
|
||||
exec("insertstring", 1, "{");
|
||||
assert.equal(editor.getValue(), "{")
|
||||
assert.equal(editor.getValue(), "{");
|
||||
exec("insertstring", 1, "\n");
|
||||
assert.equal(editor.getValue(), "{\n \n}")
|
||||
assert.equal(editor.getValue(), "{\n \n}");
|
||||
|
||||
editor.setValue("");
|
||||
exec("insertstring", 1, "(");
|
||||
|
|
@ -129,6 +130,19 @@ module.exports = {
|
|||
exec("backspace", 1);
|
||||
exec("insertstring", 1, '"');
|
||||
assert.equal(editor.getValue(), '("")');
|
||||
|
||||
editor.setValue("('foo')", 1);
|
||||
exec("gotoleft", 1);
|
||||
exec("selectleft", 1);
|
||||
exec("selectMoreBefore", 1);
|
||||
exec("insertstring", 1, "'");
|
||||
assert.equal(editor.getValue(), "('foo')");
|
||||
exec("selectleft", 1);
|
||||
exec("insertstring", 1, '"');
|
||||
assert.equal(editor.getValue(), '("foo")');
|
||||
exec("selectleft", 1);
|
||||
exec("insertstring", 1, '"');
|
||||
assert.equal(editor.getValue(), '("foo")');
|
||||
}
|
||||
};
|
||||
|
||||
|
|
|
|||
|
|
@ -256,7 +256,7 @@ var CstyleBehaviour = function() {
|
|||
text: quote + selected + quote,
|
||||
selection: false
|
||||
};
|
||||
} else {
|
||||
} else if (!selected) {
|
||||
var cursor = editor.getCursorPosition();
|
||||
var line = session.doc.getLine(cursor.row);
|
||||
var leftChar = line.substring(cursor.column-1, cursor.column);
|
||||
|
|
@ -278,7 +278,7 @@ var CstyleBehaviour = function() {
|
|||
if (stringBefore && !stringAfter)
|
||||
return null; // wrap string with different quote
|
||||
if (stringBefore && stringAfter)
|
||||
return null; // do not pair quotes inside strings
|
||||
return null; // do not pair quotes inside strings
|
||||
var wordRe = session.$mode.tokenRe;
|
||||
wordRe.lastIndex = 0;
|
||||
var isWordBefore = wordRe.test(leftChar);
|
||||
|
|
|
|||
Loading…
Add table
Add a link
Reference in a new issue