Jump to Definition variations setup

If something is selected and we have an orig cursor pos, set it back to
that. If not, we set the orig cursor pos, define an array of possible
definition matches and attempt to find them one after another in a for
loop, escaping when we do. Altered findReplace function to provide a
return of true or false depending on if anything is found.
This commit is contained in:
Matt Pass
2013-05-05 13:35:38 +01:00
parent d7a8b35ded
commit c214640bb1

View File

@@ -412,11 +412,22 @@ var ICEcoder = {
// Jump to and highlight the function definition current token
jumpToDefinition: function() {
var cM, tokenString;
var cM, tokenString, defVars;
cM = ICEcoder.getcMInstance();
tokenString = cM.getTokenAt(cM.getCursor()).string;
top.ICEcoder.findReplace("function "+tokenString,false,true);
if (cM.somethingSelected() && top.ICEcoder.origCurorPos) {
cM.setCursor(top.ICEcoder.origCurorPos);
} else {
top.ICEcoder.origCurorPos = cM.getCursor();
defVars = ["var "+tokenString, "function "+tokenString, tokenString+"=function", tokenString+"=new function", tokenString+":", "def "+tokenString, "class "+tokenString];
for (var i=0; i<defVars.length; i++) {
if (top.ICEcoder.findReplace(defVars[i],false,true)) {
i=defVars.length;
}
}
}
},
// ==============
@@ -966,8 +977,10 @@ var ICEcoder = {
cM.focus();
top.ICEcoder.findMode = true;
}
return true;
} else {
results.innerHTML = "No results";
return false;
}
} else {
// Show the relevant multiple results popup