filter : function(keyword, nosel, force){ keyword = keyword.replace(/\*/g, ""); if (!this.model.data) { this.lastSearch = keyword; return; } if (!keyword || !keyword.length) { var result = this.arrayCache.slice(); // More prioritization for already open files tabEditors.getPages().forEach(function (page) { var path = page.$doc.getNode().getAttribute("path") .substring(window.cloud9config.davPrefix.length); result.remove(path); result.unshift(path); }); this.arraySearchResults = result; } else { dgGoToFile.$viewport.setScrollTop(0); this.arraySearchResults = search.fileSearch(this.arrayCache, keyword); } this.lastSearch = keyword; this.updateDatagrid(); // See if there are open files that match the search results // and the first if in the displayed results if (nosel) return; var pages = tabEditors.getPages(), hash = {}; for (var i = pages.length - 1; i >= 0; i--) { hash[pages[i].id] = true; } var nodes = dgGoToFile.getTraverseNodes(); if (!nodes) return; for (var i = Math.max(dgGoToFile.$viewport.limit - 3, nodes.length - 1); i >= 0; i--) { if (hash[ide.davPrefix + nodes[i].firstChild.nodeValue]) { dgGoToFile.select(nodes[i]); return; } } var selNode = dgGoToFile.getFirstTraverseNode(); if (selNode) dgGoToFile.select(selNode); },
filter : function(keyword, nosel, force){ if (!this.model.data) { this.lastSearch = keyword; return; } if (!keyword) this.arraySearchResults = this.arrayCache; else { var nodes; // Optimization reusing smaller result if possible if (this.lastSearch && keyword.indexOf(this.lastSearch) > -1) nodes = this.arrayCacheLastSearch; else nodes = this.arrayCache; var cache = []; dgGoToFile.$viewport.setScrollTop(0); this.arraySearchResults = search.fileSearch(nodes, keyword, cache); this.arrayCacheLastSearch = cache; } this.lastSearch = keyword; this.updateDatagrid(); // See if there are open files that match the search results // and the first if in the displayed results if (nosel) return; var pages = tabEditors.getPages(), hash = {}; for (var i = pages.length - 1; i >= 0; i--) { hash[pages[i].id] = true; } var nodes = dgGoToFile.getTraverseNodes(); for (var i = Math.max(dgGoToFile.$viewport.limit - 3, nodes.length - 1); i >= 0; i--) { if (hash[ide.davPrefix + nodes[i].firstChild.nodeValue]) { dgGoToFile.select(nodes[i]); return; } } var selNode = dgGoToFile.getFirstTraverseNode(); if (selNode) dgGoToFile.select(selNode); },