Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Commit

Permalink
Merge pull request #4442 from shevchuk/hide-zipped-from-quick-open-re…
Browse files Browse the repository at this point in the history
…view-1

Exclude certain known binary files types from FileIndexManager (and thus Quick Open, Find in Files, etc.)
  • Loading branch information
peterflynn committed Jul 22, 2013
2 parents 34556da + e205fe5 commit 12bbef8
Show file tree
Hide file tree
Showing 3 changed files with 28 additions and 2 deletions.
8 changes: 7 additions & 1 deletion src/project/FileIndexManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -147,8 +147,14 @@ define(function (require, exports, module) {
if (!ProjectManager.shouldShow(entry)) {
return;
}

var fileInfo = new FileInfo(entry);

// skip zipped/binary files
if (ProjectManager.isBinaryFile(fileInfo.name)) {
return;
}

//console.log(entry.name);

CollectionUtils.forEach(_indexList, function (index, indexName) {
Expand Down
17 changes: 17 additions & 0 deletions src/project/ProjectManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -80,6 +80,13 @@ define(function (require, exports, module) {
*/
var _exclusionListRegEx = /\.pyc$|^\.git$|^\.gitignore$|^\.gitmodules$|^\.svn$|^\.DS_Store$|^Thumbs\.db$|^\.hg$|^CVS$|^\.cvsignore$|^\.gitattributes$|^\.hgtags$|^\.hgignore$/;

/**
* @private
* File names which are not showed in quick open dialog
* @type {RegExp}
*/
var _binaryExclusionListRegEx = /\.svgz$|\.jsz$|\.zip$|\.gz$|\.htmz$|\.htmlz$|\.rar$|\.tar$|\.exe$|\.bin$/;

/**
* @private
* Reference to the tree control container div. Initialized by
Expand Down Expand Up @@ -637,6 +644,15 @@ define(function (require, exports, module) {
function shouldShow(entry) {
return !entry.name.match(_exclusionListRegEx);
}

/**
* Returns true if fileName's extension doesn't belong to binary (e.g. archived)
* @param {string} fileName
* @return {boolean}
*/
function isBinaryFile(fileName) {
return fileName.match(_binaryExclusionListRegEx);
}

/**
* @private
Expand Down Expand Up @@ -1559,6 +1575,7 @@ define(function (require, exports, module) {
exports.isWithinProject = isWithinProject;
exports.makeProjectRelativeIfPossible = makeProjectRelativeIfPossible;
exports.shouldShow = shouldShow;
exports.isBinaryFile = isBinaryFile;
exports.openProject = openProject;
exports.getSelectedItem = getSelectedItem;
exports.getInitialProjectPath = getInitialProjectPath;
Expand Down
5 changes: 4 additions & 1 deletion src/search/QuickOpen.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,10 @@ define(function (require, exports, module) {
var filteredList = $.map(fileList, function (fileInfo) {
// Is it a match at all?
// match query against the full path (with gaps between query characters allowed)
var searchResult = matcher.match(ProjectManager.makeProjectRelativeIfPossible(fileInfo.fullPath), query);
var searchResult;

searchResult = matcher.match(ProjectManager.makeProjectRelativeIfPossible(fileInfo.fullPath), query);

if (searchResult) {
searchResult.label = fileInfo.name;
searchResult.fullPath = fileInfo.fullPath;
Expand Down

0 comments on commit 12bbef8

Please sign in to comment.