|
56 | 56 | startLine = cM.getCursor(true).line; |
57 | 57 | endLine = cM.getCursor().line; |
58 | 58 | for (var i=startLine; i<=endLine; i++) { |
59 | | - cM.setLine(i, cM.getLine(i).slice(0,1)!=commentChar |
| 59 | + cM.replaceRange(cM.getLine(i).slice(0,1)!=commentChar |
60 | 60 | ? commentChar + cM.getLine(i) |
61 | | - : cM.getLine(i).slice(1,cM.getLine(i).length)); |
| 61 | + : cM.getLine(i).slice(1,cM.getLine(i).length), {line:i, ch:0}, {line:i, ch:1000000}); |
62 | 62 | } |
63 | 63 | } else if (["Lua"].indexOf(top.ICEcoder.caretLocType)>-1) { |
64 | 64 | cM.replaceSelection(cM.getSelection().slice(0,4)!="--[[" |
65 | 65 | ? "--[[" + cM.getSelection() + "]]" |
66 | | - : cM.getSelection().slice(4,cM.getSelection().length-2)); |
| 66 | + : cM.getSelection().slice(4,cM.getSelection().length-2),"around"); |
67 | 67 | } else { |
68 | 68 | cM.replaceSelection(cM.getSelection().slice(0,2)!="/*" |
69 | 69 | ? "/*" + cM.getSelection() + "*/" |
70 | | - : cM.getSelection().slice(2,cM.getSelection().length-2)); |
| 70 | + : cM.getSelection().slice(2,cM.getSelection().length-2),"around"); |
71 | 71 | } |
72 | 72 | } else { |
73 | 73 | if (["CoffeeScript","CSS","SQL"].indexOf(top.ICEcoder.caretLocType)>-1) { |
74 | | - cM.setLine(linePos, lineContent.slice(0,2)!="/*" |
| 74 | + cM.replaceRange(lineContent.slice(0,2)!="/*" |
75 | 75 | ? "/*" + lineContent + "*/" |
76 | | - : lineContent.slice(2,lCLen).slice(0,lCLen-4)); |
| 76 | + : lineContent.slice(2,lCLen).slice(0,lCLen-4), {line: linePos, ch: 0}, {line: linePos, ch: 1000000}); |
77 | 77 | if (lineContent.slice(0,2)=="/*") {adjustCursor = -adjustCursor}; |
78 | 78 | } else if (["Ruby","Python","Erlang","Julia","YAML","Perl"].indexOf(top.ICEcoder.caretLocType)>-1) { |
79 | 79 | commentChar = top.ICEcoder.caretLocType == "Erlang" ? "%" : "#"; |
80 | | - cM.setLine(linePos, lineContent.slice(0,1)!=commentChar |
| 80 | + cM.replaceRange(lineContent.slice(0,1)!=commentChar |
81 | 81 | ? commentChar + lineContent |
82 | | - : lineContent.slice(1,lCLen)); |
| 82 | + : lineContent.slice(1,lCLen), {line: linePos, ch: 0}, {line: linePos, ch: 1000000}); |
83 | 83 | adjustCursor = 1; |
84 | 84 | if (lineContent.slice(0,1)==commentChar) {adjustCursor = -adjustCursor}; |
85 | 85 | } else if (["Lua"].indexOf(top.ICEcoder.caretLocType)>-1) { |
86 | | - cM.setLine(linePos, lineContent.slice(0,2)!="--" |
| 86 | + cM.replaceRange(lineContent.slice(0,2)!="--" |
87 | 87 | ? "--" + lineContent |
88 | | - : lineContent.slice(2,lCLen)); |
| 88 | + : lineContent.slice(2,lCLen), {line: linePos, ch: 0}, {line: linePos, ch: 1000000}); |
89 | 89 | if (lineContent.slice(0,2)=="//") {adjustCursor = -adjustCursor}; |
90 | 90 | } else { |
91 | | - cM.setLine(linePos, lineContent.slice(0,2)!="//" |
| 91 | + cM.replaceRange(lineContent.slice(0,2)!="//" |
92 | 92 | ? "//" + lineContent |
93 | | - : lineContent.slice(2,lCLen)); |
| 93 | + : lineContent.slice(2,lCLen), {line: linePos, ch: 0}, {line: linePos, ch: 1000000}); |
94 | 94 | if (lineContent.slice(0,2)=="//") {adjustCursor = -adjustCursor}; |
95 | 95 | } |
96 | 96 | } |
97 | 97 | } else { |
98 | 98 | if (cM.somethingSelected()) { |
99 | 99 | cM.replaceSelection(cM.getSelection().slice(0,4)!="<\!--" |
100 | 100 | ? "<\!--" + cM.getSelection() + "//-->" |
101 | | - : cM.getSelection().slice(4,cM.getSelection().length-5)); |
| 101 | + : cM.getSelection().slice(4,cM.getSelection().length-5),"around"); |
102 | 102 | } else { |
103 | | - cM.setLine(linePos, lineContent.slice(0,4)!="<\!--" |
| 103 | + cM.replaceRange(lineContent.slice(0,4)!="<\!--" |
104 | 104 | ? "<\!--" + lineContent + "//-->" |
105 | | - : lineContent.slice(4,lCLen).slice(0,lCLen-9)); |
| 105 | + : lineContent.slice(4,lCLen).slice(0,lCLen-9), {line: linePos, ch: 0}, {line: linePos, ch: 1000000}); |
106 | 106 | adjustCursor = lineContent.slice(0,4)=="<\!--" ? -4 : 4; |
107 | 107 | } |
108 | 108 | } |
|
0 commit comments