Remove unneeded regex matching for built-in ignores

This commit is contained in:
Kevin Sawicki 2012-10-08 22:26:35 -07:00
parent f71b90578e
commit 71c161d527
2 changed files with 24 additions and 13 deletions

View File

@ -121,6 +121,7 @@ bool Native::Execute(const CefString& name,
strncpy(relative, entry->fts_path + rootPathLength, pathLength);
args.clear();
args.push_back(CefV8Value::CreateString(relative));
args.push_back(CefV8Value::CreateString(entry->fts_name));
args.push_back(CefV8Value::CreateBool((entry->fts_info & FTS_F) != 0));
if (!function->ExecuteFunction(function, args)->GetBoolValue())
fts_set(tree, entry, FTS_SKIP);

View File

@ -22,10 +22,13 @@ class Project
@setPath(path)
@editSessions = []
@buffers = []
@ignoredPathRegexes = [
/\.DS_Store$/
/(^|\/)\.git(\/|$)/
@ignoredFolderNames = [
'.git'
]
@ignoredFileNames = [
'.DS_Store'
]
@ignoredPathRegexes = []
destroy: ->
editSession.destroy() for editSession in @getEditSessions()
@ -52,19 +55,26 @@ class Project
filePaths = []
fs.traverseTree @getPath(), (path, isFile) =>
if @ignorePath(path)
false
else if isFile
filePaths.push path
false
else
true
fs.traverseTree @getPath(), (path, name, isFile) =>
return false if @ignorePath(path, name, isFile)
filePaths.push path if isFile
return not isFile
deferred.resolve filePaths
deferred
ignorePath: (path) ->
_.find @ignoredPathRegexes, (regex) -> path.match(regex)
ignorePath: (path, name, isFile) ->
if isFile
for ignored in @ignoredFileNames
return true if name is ignored
else
for ignored in @ignoredFolderNames
return true if name is ignored
for regex in @ignoredPathRegexes
return true if path.match(regex)
return false
ignorePathRegex: ->
@ignoredPathRegexes.map((regex) -> "(#{regex.source})").join("|")