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

Review fixes https://github.com/adobe/brackets/pull/4382 #4442

Merged
Merged
Show file tree
Hide file tree
Changes from 1 commit
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
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$/;
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

You don't want the ^s here -- that means only ".zip" will match, not "foo.zip". The only reason the _exclusionListRegEx uses ^ is because it really is filtering out exact names in those cases (e.g. ".svn" isn't an extension, it's a complete folder name).


/**
* @private
* Reference to the tree control container div. Initialized by
Expand Down Expand Up @@ -636,6 +643,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 @@ -1553,6 +1569,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
7 changes: 6 additions & 1 deletion src/search/QuickOpen.js
Original file line number Diff line number Diff line change
Expand Up @@ -502,7 +502,12 @@ 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;

if (!ProjectManager.isBinaryFile(fileInfo.name)) {
searchResult = matcher.match(ProjectManager.makeProjectRelativeIfPossible(fileInfo.fullPath), query);
}
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Sorry for bringing this up late, but I think it'd actually be better to do the filtering more centrally for consistency -- for example, Find in Files should also ignore binary files.

So, let's move this to FileIndexManager, right after the shouldShow() check in _addFileToIndexes(). That will filter binary files out of all search-related functionality while leaving them visible in the project tree. Exactly what we want, I think.

(As I mentioned before, once images are openable we'll need to adjust this to distinguish readable binary files from non-readable, but we can deal with that later)


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