className gone, need to use type

className dropped by CodeMirror, need to pick up "error" from type
As it may not be there, we need to test for its existence and it's also
be part of a string eg "tag brackets error", so indexOf is needed
This commit is contained in:
Matt Pass
2014-06-18 16:52:01 +01:00
parent 5d4e22d363
commit 5aa5dc82bb

View File

@@ -134,13 +134,14 @@ top.ICEcoder.getNestLocationSub = function(nestCheck, fileName) {
// Indicate if the nesting structure of the code is OK
top.ICEcoder.updateNestingIndicator = function() {
var cM, nestOK, fileName;
var cM, testToken, nestOK, fileName;
cM = top.ICEcoder.getcMInstance();
nestOK = true;
fileName = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1];
if (cM && fileName && ["js","coffee","css","less","sql","erl","yaml","java","jl","c","cpp","cs","go","lua","pl","rs","scss"].indexOf(fileName.split(".")[1])==-1) {
nestOK = cM.getTokenAt({line:cM.lineCount(),ch:cM.lineInfo(cM.lineCount()-1).text.length}).className != "error" ? true : false;
testToken = cM.getTokenAt({line:cM.lineCount(),ch:cM.lineInfo(cM.lineCount()-1).text.length});
nestOK = testToken.type && testToken.type.indexOf("error") == -1 ? true : false;
}
top.ICEcoder.nestValid.style.background = nestOK ? "#0b0" : "#f00";
top.ICEcoder.nestValid.title = nestOK ? "Nesting OK" : "Nesting Broken";