|
13 | 13 |
|
14 | 14 | // Switch the CodeMirror mode on demand |
15 | 15 | top.ICEcoder.switchMode = function(mode) { |
16 | | - var cM, fileName, fileExt; |
| 16 | + var cM, cMdiff, thisCM, fileName, fileExt; |
17 | 17 |
|
18 | 18 | cM = top.ICEcoder.getcMInstance(); |
| 19 | + cMdiff = top.ICEcoder.getcMdiffInstance(); |
| 20 | + thisCM = top.ICEcoder.editorFocusInstance.indexOf('diff') > -1 ? cMdiff : cM; |
19 | 21 | 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) { |
23 | 25 | fileExt = fileName.split("."); |
24 | 26 | fileExt = fileExt[fileExt.length-1]; |
25 | | - cM.setOption("mode", |
| 27 | + thisCM.setOption("mode", |
26 | 28 | fileExt == "js" ? "text/javascript" |
27 | 29 | : fileExt == "coffee" ? "text/x-coffeescript" |
28 | 30 | : fileExt == "rb" ? "text/x-ruby" |
|
141 | 143 |
|
142 | 144 | // Indicate if the nesting structure of the code is OK |
143 | 145 | top.ICEcoder.updateNestingIndicator = function() { |
144 | | - var cM, testToken, nestOK, fileName, fileExt; |
| 146 | + var cM, cMdiff, thisCM, testToken, nestOK, fileName, fileExt; |
145 | 147 |
|
146 | 148 | cM = top.ICEcoder.getcMInstance(); |
| 149 | + cMdiff = top.ICEcoder.getcMdiffInstance(); |
| 150 | + thisCM = top.ICEcoder.editorFocusInstance.indexOf('diff') > -1 ? cMdiff : cM; |
147 | 151 | nestOK = true; |
148 | 152 | fileName = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1]; |
149 | 153 | if (fileName) { |
150 | 154 | fileExt = fileName.split("."); |
151 | 155 | fileExt = fileExt[fileExt.length-1]; |
152 | 156 | } |
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}); |
155 | 159 | nestOK = testToken.type && testToken.type.indexOf("error") == -1 ? true : false; |
156 | 160 | } |
157 | 161 | top.ICEcoder.nestValid.style.background = nestOK ? "#0b0" : "#f00"; |
|
160 | 164 |
|
161 | 165 | // Determine which area of the document we're in |
162 | 166 | top.ICEcoder.caretLocationType = function() { |
163 | | - var cM, caretLocType, caretChunk, fileName, fileExt; |
| 167 | + var cM, cMdiff, thisCM, caretLocType, caretChunk, fileName, fileExt; |
164 | 168 |
|
165 | 169 | cM = top.ICEcoder.getcMInstance(); |
| 170 | + cMdiff = top.ICEcoder.getcMdiffInstance(); |
| 171 | + thisCM = top.ICEcoder.editorFocusInstance.indexOf('diff') > -1 ? cMdiff : cM; |
166 | 172 | caretLocType = "Unknown"; |
167 | | - caretChunk = cM.getValue().substr(0,top.ICEcoder.caretPos+1); |
| 173 | + caretChunk = thisCM.getValue().substr(0,top.ICEcoder.caretPos+1); |
168 | 174 |
|
169 | 175 | if(caretChunk.lastIndexOf("<script")>caretChunk.lastIndexOf("/script>")&&caretLocType=="Unknown") {caretLocType = "JavaScript";} |
170 | 176 | else if (caretChunk.lastIndexOf("<?")>caretChunk.lastIndexOf("?>")&&caretLocType=="Unknown") {caretLocType = "PHP";} |
|
0 commit comments