diff --git a/lib/ice-coder.js b/lib/ice-coder.js index 56c6a9f..b7d6460 100644 --- a/lib/ice-coder.js +++ b/lib/ice-coder.js @@ -700,8 +700,8 @@ var ICEcoder = { var word = (cM.getRange(cM.findWordAt(cM.getCursor()).anchor, cM.findWordAt(cM.getCursor()).head)); // Get result and number of results for word in functions and classes from index JSON object list - result = null; - numResults = 0; + var result = null; + var numResults = 0; var filePath = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1]; var filePathExt = filePath.substr(filePath.lastIndexOf(".")+1); for(i in top.ICEcoder.indexData.functions[filePathExt]) { @@ -720,16 +720,16 @@ var ICEcoder = { // If we have a single result and the cursor isn't already on the definition of it we can jump to where it's defined if (numResults === 1 && [null,"def"].indexOf(cM.getTokenTypeAt(cM.getCursor())) === -1) { top.ICEcoder.openFile(result.filePath.replace(top.docRoot,"")); - top.ICEcoder.goFindAfterOpenInt = setInterval(function(){ + top.ICEcoder.goFindAfterOpenInt = setInterval(function(result){ if (top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1] == result.filePath.replace(top.docRoot,"") && !top.ICEcoder.loadingFile) { cM = top.ICEcoder.getcMInstance(); - setTimeout(function() { + setTimeout(function(result) { top.ICEcoder.goToLine(result.range.from.line+1); cM.setSelection({line: result.range.from.line, ch: result.range.from.ch}, {line: result.range.to.line, ch: result.range.to.ch}); - },20); + },20,result); clearInterval(top.ICEcoder.goFindAfterOpenInt); } - },20); + },20,result); } top.ICEcoder.mouseDownInCM = "editor";