|
17 | 17 | if (cm.somethingSelected()) return CodeMirror.Pass;
|
18 | 18 | var cur = cm.getCursor(), line = cm.getLine(cur.line);
|
19 | 19 | if (cur.ch && cur.ch < line.length &&
|
20 |
| - pairs.indexOf(line.slice(cur.ch - 1, cur.ch + 1)) % 2 == 0) |
| 20 | + pairs.indexOf(line.slice(cur.ch - 1, cur.ch + 1)) % 2 == 0) |
21 | 21 | cm.replaceRange("", CodeMirror.Pos(cur.line, cur.ch - 1), CodeMirror.Pos(cur.line, cur.ch + 1));
|
22 | 22 | else
|
23 | 23 | return CodeMirror.Pass;
|
|
27 | 27 | for (var i = 0; i < pairs.length; i += 2) (function(left, right) {
|
28 | 28 | if (left != right) closingBrackets.push(right);
|
29 | 29 | function surround(cm) {
|
30 |
| - var selection = cm.getSelection(); |
31 |
| - cm.replaceSelection(left + selection + right); |
| 30 | + var selection = cm.getSelection(); |
| 31 | + cm.replaceSelection(left + selection + right); |
32 | 32 | }
|
33 | 33 | function maybeOverwrite(cm) {
|
34 | 34 | var cur = cm.getCursor(), ahead = cm.getRange(cur, CodeMirror.Pos(cur.line, cur.ch + 1));
|
35 | 35 | if (ahead != right || cm.somethingSelected()) return CodeMirror.Pass;
|
36 | 36 | else cm.execCommand("goCharRight");
|
37 | 37 | }
|
38 | 38 | map["'" + left + "'"] = function(cm) {
|
| 39 | + var type = cm.getTokenAt(cm.getCursor()).type; |
| 40 | + if (left === "'" && type === "comment") { |
| 41 | + cm.replaceSelection("'", {head: ahead, anchor: ahead}); |
| 42 | + return; |
| 43 | + } |
39 | 44 | if (cm.somethingSelected()) return surround(cm);
|
40 | 45 | if (left == right && maybeOverwrite(cm) != CodeMirror.Pass) return;
|
41 | 46 | var cur = cm.getCursor(), ahead = CodeMirror.Pos(cur.line, cur.ch + 1);
|
|
0 commit comments