Skip to content

Commit d348191

Browse files
committed
Handling split panes
Establish panes and which one we are looking at when running these functions Note: May need to not do this for switchMode, as the diff pane should fall in line with the main pane
1 parent 3958742 commit d348191

1 file changed

Lines changed: 16 additions & 10 deletions

File tree

processes/on-editor-load.php

Lines changed: 16 additions & 10 deletions
Original file line numberDiff line numberDiff line change
@@ -13,16 +13,18 @@
1313

1414
// Switch the CodeMirror mode on demand
1515
top.ICEcoder.switchMode = function(mode) {
16-
var cM, fileName, fileExt;
16+
var cM, cMdiff, thisCM, fileName, fileExt;
1717

1818
cM = top.ICEcoder.getcMInstance();
19+
cMdiff = top.ICEcoder.getcMdiffInstance();
20+
thisCM = top.ICEcoder.editorFocusInstance.indexOf('diff') > -1 ? cMdiff : cM;
1921
fileName = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
20-
if (cM && mode) {
21-
cM.setOption("mode",mode);
22-
} else if (cM && fileName) {
22+
if (thisCM && mode) {
23+
thisCM.setOption("mode",mode);
24+
} else if (thisCM && fileName) {
2325
fileExt = fileName.split(".");
2426
fileExt = fileExt[fileExt.length-1];
25-
cM.setOption("mode",
27+
thisCM.setOption("mode",
2628
fileExt == "js" ? "text/javascript"
2729
: fileExt == "coffee" ? "text/x-coffeescript"
2830
: fileExt == "rb" ? "text/x-ruby"
@@ -141,17 +143,19 @@
141143

142144
// Indicate if the nesting structure of the code is OK
143145
top.ICEcoder.updateNestingIndicator = function() {
144-
var cM, testToken, nestOK, fileName, fileExt;
146+
var cM, cMdiff, thisCM, testToken, nestOK, fileName, fileExt;
145147

146148
cM = top.ICEcoder.getcMInstance();
149+
cMdiff = top.ICEcoder.getcMdiffInstance();
150+
thisCM = top.ICEcoder.editorFocusInstance.indexOf('diff') > -1 ? cMdiff : cM;
147151
nestOK = true;
148152
fileName = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
149153
if (fileName) {
150154
fileExt = fileName.split(".");
151155
fileExt = fileExt[fileExt.length-1];
152156
}
153-
if (cM && fileName && ["js","coffee","css","less","sql","erl","yaml","java","jl","c","cpp","cs","go","lua","pl","rs","scss"].indexOf(fileExt)==-1) {
154-
testToken = cM.getTokenAt({line:cM.lineCount(),ch:cM.lineInfo(cM.lineCount()-1).text.length});
157+
if (thisCM && fileName && ["js","coffee","css","less","sql","erl","yaml","java","jl","c","cpp","cs","go","lua","pl","rs","scss"].indexOf(fileExt)==-1) {
158+
testToken = thisCM.getTokenAt({line:thisCM.lineCount(),ch:thisCM.lineInfo(thisCM.lineCount()-1).text.length});
155159
nestOK = testToken.type && testToken.type.indexOf("error") == -1 ? true : false;
156160
}
157161
top.ICEcoder.nestValid.style.background = nestOK ? "#0b0" : "#f00";
@@ -160,11 +164,13 @@
160164

161165
// Determine which area of the document we're in
162166
top.ICEcoder.caretLocationType = function() {
163-
var cM, caretLocType, caretChunk, fileName, fileExt;
167+
var cM, cMdiff, thisCM, caretLocType, caretChunk, fileName, fileExt;
164168

165169
cM = top.ICEcoder.getcMInstance();
170+
cMdiff = top.ICEcoder.getcMdiffInstance();
171+
thisCM = top.ICEcoder.editorFocusInstance.indexOf('diff') > -1 ? cMdiff : cM;
166172
caretLocType = "Unknown";
167-
caretChunk = cM.getValue().substr(0,top.ICEcoder.caretPos+1);
173+
caretChunk = thisCM.getValue().substr(0,top.ICEcoder.caretPos+1);
168174

169175
if(caretChunk.lastIndexOf("<script")>caretChunk.lastIndexOf("/script>")&&caretLocType=="Unknown") {caretLocType = "JavaScript";}
170176
else if (caretChunk.lastIndexOf("<?")>caretChunk.lastIndexOf("?>")&&caretLocType=="Unknown") {caretLocType = "PHP";}

0 commit comments

Comments
 (0)