Skip to content

Commit 2136ad1

Browse files
committed
setLine now replaceRange, around on getSelection
setLine deprecated, now need to use replaceRange and pass 2 objects for start & end (line & ch) getSelection needs "around" param as default is now "end"
1 parent fa97918 commit 2136ad1

1 file changed

Lines changed: 15 additions & 15 deletions

File tree

processes/on-editor-load.php

Lines changed: 15 additions & 15 deletions
Original file line numberDiff line numberDiff line change
@@ -56,53 +56,53 @@
5656
startLine = cM.getCursor(true).line;
5757
endLine = cM.getCursor().line;
5858
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
6060
? 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});
6262
}
6363
} else if (["Lua"].indexOf(top.ICEcoder.caretLocType)>-1) {
6464
cM.replaceSelection(cM.getSelection().slice(0,4)!="--[["
6565
? "--[[" + cM.getSelection() + "]]"
66-
: cM.getSelection().slice(4,cM.getSelection().length-2));
66+
: cM.getSelection().slice(4,cM.getSelection().length-2),"around");
6767
} else {
6868
cM.replaceSelection(cM.getSelection().slice(0,2)!="/*"
6969
? "/*" + cM.getSelection() + "*/"
70-
: cM.getSelection().slice(2,cM.getSelection().length-2));
70+
: cM.getSelection().slice(2,cM.getSelection().length-2),"around");
7171
}
7272
} else {
7373
if (["CoffeeScript","CSS","SQL"].indexOf(top.ICEcoder.caretLocType)>-1) {
74-
cM.setLine(linePos, lineContent.slice(0,2)!="/*"
74+
cM.replaceRange(lineContent.slice(0,2)!="/*"
7575
? "/*" + 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});
7777
if (lineContent.slice(0,2)=="/*") {adjustCursor = -adjustCursor};
7878
} else if (["Ruby","Python","Erlang","Julia","YAML","Perl"].indexOf(top.ICEcoder.caretLocType)>-1) {
7979
commentChar = top.ICEcoder.caretLocType == "Erlang" ? "%" : "#";
80-
cM.setLine(linePos, lineContent.slice(0,1)!=commentChar
80+
cM.replaceRange(lineContent.slice(0,1)!=commentChar
8181
? commentChar + lineContent
82-
: lineContent.slice(1,lCLen));
82+
: lineContent.slice(1,lCLen), {line: linePos, ch: 0}, {line: linePos, ch: 1000000});
8383
adjustCursor = 1;
8484
if (lineContent.slice(0,1)==commentChar) {adjustCursor = -adjustCursor};
8585
} else if (["Lua"].indexOf(top.ICEcoder.caretLocType)>-1) {
86-
cM.setLine(linePos, lineContent.slice(0,2)!="--"
86+
cM.replaceRange(lineContent.slice(0,2)!="--"
8787
? "--" + lineContent
88-
: lineContent.slice(2,lCLen));
88+
: lineContent.slice(2,lCLen), {line: linePos, ch: 0}, {line: linePos, ch: 1000000});
8989
if (lineContent.slice(0,2)=="//") {adjustCursor = -adjustCursor};
9090
} else {
91-
cM.setLine(linePos, lineContent.slice(0,2)!="//"
91+
cM.replaceRange(lineContent.slice(0,2)!="//"
9292
? "//" + lineContent
93-
: lineContent.slice(2,lCLen));
93+
: lineContent.slice(2,lCLen), {line: linePos, ch: 0}, {line: linePos, ch: 1000000});
9494
if (lineContent.slice(0,2)=="//") {adjustCursor = -adjustCursor};
9595
}
9696
}
9797
} else {
9898
if (cM.somethingSelected()) {
9999
cM.replaceSelection(cM.getSelection().slice(0,4)!="<\!--"
100100
? "<\!--" + cM.getSelection() + "//-->"
101-
: cM.getSelection().slice(4,cM.getSelection().length-5));
101+
: cM.getSelection().slice(4,cM.getSelection().length-5),"around");
102102
} else {
103-
cM.setLine(linePos, lineContent.slice(0,4)!="<\!--"
103+
cM.replaceRange(lineContent.slice(0,4)!="<\!--"
104104
? "<\!--" + 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});
106106
adjustCursor = lineContent.slice(0,4)=="<\!--" ? -4 : 4;
107107
}
108108
}

0 commit comments

Comments
 (0)