Skip to main content

FindInFiles

Import :

const FindInFiles = brackets.getModule("search/FindInFiles")

searchModel : SearchModel

The search query and results model.

Kind: global variable

@type : Object

Token used to indicate a specific reason for zero search results

Kind: global constant

getCandidateFiles(scope) ⇒ $.Promise

Finds all candidate files to search in the given scope's subtree that are not binary content. Does NOT apply the current filter yet.

Kind: global function
Returns: $.Promise - A promise that will be resolved with the list of files in the scope. Never rejected.

ParamTypeDescription
scopeFileSystemEntrySearch scope, or null if whole project

doSearchInScope(queryInfo, scope, filter, replaceText, candidateFilesPromise) ⇒ $.Promise

Does a search in the given scope with the given filter. Used when you want to start a search programmatically. Make sure that project indexing is complete by calling isProjectIndexingComplete() Else, an empty result will be returned if search is invoked before any files are indexed.

Kind: global function
Returns: $.Promise - A promise that's resolved with the search results or rejected when the find competes.

ParamTypeDescription
queryInfoObjectQuery info object
scopeEntryProject file/subfolder to search within; else searches whole project.
filterstringA "compiled" filter as returned by FileFilters.compile(), or null for no filter
replaceTextstringIf this is a replacement, the text to replace matches with. This is just stored in the model for later use - the replacement is not actually performed right now.
candidateFilesPromise$.PromiseIf specified, a promise that should resolve with the same set of files that getCandidateFiles(scope) would return.

doReplace(results, replaceText, options, item, error) ⇒ $.Promise

Replaces a set of search results with the specified replaceText, either on disk or in memory.

Kind: global function
Returns: $.Promise - A promise that resolves when the replacement is finished or is rejected with an array of errors if any occur. Each item in the array will be an object containing:

ParamTypeDescription
resultsObject- The list of results to replace, as returned from _doSearch.
replaceTextstringThe text to replace each result with.
optionsObjectAn options object:
options.forceFilesOpenbooleanWhether to open all files in editors and perform replacements there instead of on disk. Note that even if this is false, replacements will still occur in memory for files already open in editors.
options.isRegexpbooleanIndicates if the original query was a regular expression. If true, $-substitution is applied to the replaceText.
itemstringThe full path to the file that could not be updated.
errorstringEither a FileSystem error or one of the FindInFiles.ERROR_* constants.

getNextPageofSearchResults() ⇒ object

Gets the next page of search results to append to the result set.

Kind: global function
Returns: object - A promise that's resolved with the search results or rejected when the find competes.

getAllSearchResults() ⇒ object

Get all the search results.

Kind: global function
Returns: object - A promise that's resolved with the search results or rejected when the find competes.