From b0dc96c88836cfeccb76c9e5d108a0142f5a1497 Mon Sep 17 00:00:00 2001 From: Matt Pass Date: Mon, 10 Jun 2013 09:53:07 +0100 Subject: [PATCH] Edge case changing on item existance Only look to update hints if we have at least 1 open file We can also only determine the type of fileName for code folding if we have a filename The same is true for the previewWindow, can only look to do this if we have a file open These are all edge cases highlighted through unit testing --- editor.php | 14 ++++++++------ 1 file changed, 8 insertions(+), 6 deletions(-) diff --git a/editor.php b/editor.php index 02d7059..4b9a56b 100644 --- a/editor.php +++ b/editor.php @@ -211,18 +211,20 @@ function createNewCMInstance(num) { top.document.getElementById('results').innerHTML = top.ICEcoder.results.length + " results"; top.ICEcoder.findMode = false; } - if (top.ICEcoder.codeAssist) { + if (top.ICEcoder.codeAssist && top.ICEcoder.openFiles.length>0) { clearTimeout(window['cM'+num+'waiting']); window['cM'+num+'waiting'] = setTimeout(top.ICEcoder.updateHints, 100); } var filepath = top.ICEcoder.openFiles[top.ICEcoder.selectedTab-1]; - var filename = filepath.substr(filepath.lastIndexOf("/")+1); - var fileExt = filename.substr(filename.lastIndexOf(".")+1); - for (var i=changeObj.from.line; i -1 ? "braceRangeFinder" : "tagRangeFinder"],null,"+","-",true)(thisCM, i); + if (filepath) { + var filename = filepath.substr(filepath.lastIndexOf("/")+1); + var fileExt = filename.substr(filename.lastIndexOf(".")+1); + for (var i=changeObj.from.line; i -1 ? "braceRangeFinder" : "tagRangeFinder"],null,"+","-",true)(thisCM, i); + } } // Update HTML edited files live - if (top.ICEcoder.previewWindow.location) { + if (filepath && top.ICEcoder.previewWindow.location) { if (top.ICEcoder.previewWindow.location.pathname==filepath) { if (["htm","html","txt"].indexOf(fileExt) > -1) { top.ICEcoder.previewWindow.document.documentElement.innerHTML = window['cM'+num].getValue();