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

Commit 12bbef8

Browse files
committed
Merge pull request #4442 from shevchuk/hide-zipped-from-quick-open-review-1
Exclude certain known binary files types from FileIndexManager (and thus Quick Open, Find in Files, etc.)
2 parents 34556da + e205fe5 commit 12bbef8

3 files changed

Lines changed: 28 additions & 2 deletions

File tree

src/project/FileIndexManager.js

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -147,8 +147,14 @@ define(function (require, exports, module) {
147147
if (!ProjectManager.shouldShow(entry)) {
148148
return;
149149
}
150-
150+
151151
var fileInfo = new FileInfo(entry);
152+
153+
// skip zipped/binary files
154+
if (ProjectManager.isBinaryFile(fileInfo.name)) {
155+
return;
156+
}
157+
152158
//console.log(entry.name);
153159

154160
CollectionUtils.forEach(_indexList, function (index, indexName) {

src/project/ProjectManager.js

Lines changed: 17 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -80,6 +80,13 @@ define(function (require, exports, module) {
8080
*/
8181
var _exclusionListRegEx = /\.pyc$|^\.git$|^\.gitignore$|^\.gitmodules$|^\.svn$|^\.DS_Store$|^Thumbs\.db$|^\.hg$|^CVS$|^\.cvsignore$|^\.gitattributes$|^\.hgtags$|^\.hgignore$/;
8282

83+
/**
84+
* @private
85+
* File names which are not showed in quick open dialog
86+
* @type {RegExp}
87+
*/
88+
var _binaryExclusionListRegEx = /\.svgz$|\.jsz$|\.zip$|\.gz$|\.htmz$|\.htmlz$|\.rar$|\.tar$|\.exe$|\.bin$/;
89+
8390
/**
8491
* @private
8592
* Reference to the tree control container div. Initialized by
@@ -637,6 +644,15 @@ define(function (require, exports, module) {
637644
function shouldShow(entry) {
638645
return !entry.name.match(_exclusionListRegEx);
639646
}
647+
648+
/**
649+
* Returns true if fileName's extension doesn't belong to binary (e.g. archived)
650+
* @param {string} fileName
651+
* @return {boolean}
652+
*/
653+
function isBinaryFile(fileName) {
654+
return fileName.match(_binaryExclusionListRegEx);
655+
}
640656

641657
/**
642658
* @private
@@ -1559,6 +1575,7 @@ define(function (require, exports, module) {
15591575
exports.isWithinProject = isWithinProject;
15601576
exports.makeProjectRelativeIfPossible = makeProjectRelativeIfPossible;
15611577
exports.shouldShow = shouldShow;
1578+
exports.isBinaryFile = isBinaryFile;
15621579
exports.openProject = openProject;
15631580
exports.getSelectedItem = getSelectedItem;
15641581
exports.getInitialProjectPath = getInitialProjectPath;

src/search/QuickOpen.js

Lines changed: 4 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -502,7 +502,10 @@ define(function (require, exports, module) {
502502
var filteredList = $.map(fileList, function (fileInfo) {
503503
// Is it a match at all?
504504
// match query against the full path (with gaps between query characters allowed)
505-
var searchResult = matcher.match(ProjectManager.makeProjectRelativeIfPossible(fileInfo.fullPath), query);
505+
var searchResult;
506+
507+
searchResult = matcher.match(ProjectManager.makeProjectRelativeIfPossible(fileInfo.fullPath), query);
508+
506509
if (searchResult) {
507510
searchResult.label = fileInfo.name;
508511
searchResult.fullPath = fileInfo.fullPath;

0 commit comments

Comments
 (0)