Skip to main content

FindUtils

Import :

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

parseDollars(replaceWith, match) ⇒ string

Given a replace string that contains $-expressions, replace them with data from the given regexp match info. NOTE: we can't just use the ordinary replace() function here because the string has been extracted from the original text and so might be missing some context that the regexp matched.

Kind: global function
Returns: string - The replace text with the $-expressions substituted.

ParamTypeDescription
replaceWithstringThe string containing the $-expressions.
matchObjectThe match data from the regexp.

performReplacements(results, replaceText, options) ⇒ $.Promise

Given a set of search results, replaces them with the given replaceText, either on disk or in memory. Checks timestamps to ensure replacements are not performed in files that have changed on disk since the original search results were generated. However, does not check whether edits have been performed in in-memory documents since the search; it's up to the caller to guarantee this hasn't happened. (When called from the standard Find in Files UI, SearchResultsView guarantees this. If called headlessly, the caller needs to track changes.)

Replacements in documents that are already open in memory at the start of the replacement are guaranteed to happen synchronously; replacements in files on disk will return an error if the on-disk file changes between the time performReplacements() is called and the time the replacement actually happens.

Kind: global function
Returns: $.Promise - A promise that's resolved when the replacement is finished or rejected with an array of errors if there were one or more errors. Each individual item in the array will be a {item: string, error: string} object, where item is the full path to the file that could not be updated, and error is either a FileSystem error or one of the FindUtils.ERROR_* constants.

ParamTypeDescription
resultsObjectThe list of results to replace, as returned from _doSearch.
replaceTextstringThe text to replace each result with.
optionsObjectAn options object:
[options.forceFilesOpen]booleanWhether to open all files in editors and do replacements there rather than doing the replacements on disk. Note that even if this is false, files that are already open in editors will have replacements done in memory.
[options.isRegexp]booleanWhether the original query was a regexp. If true, $-substitution is performed on the replaceText.

labelForScope(scope) ⇒ string

Returns label text to indicate the search scope. Already HTML-escaped.

Kind: global function

ParamType
scopeEntry

parseQueryInfo(queryInfo) ⇒ Object

Parses the given query into a regexp, and returns whether it was valid or not.

Kind: global function
Returns: Object - queryExpr - the regexp representing the query valid - set to true if query is a nonempty string or a valid regexp. empty - set to true if query was empty. error - set to an error string if valid is false and query is nonempty.

ParamType
queryInfoObject

prioritizeOpenFile(files, firstFile) ⇒ Array.<*>

Prioritizes the open file and then the working set files to the starting of the list of files

Kind: global function

ParamTypeDescription
filesArray.<*>An array of file paths or file objects to sort
firstFilestringIf specified, the path to the file that should be sorted to the top.

getOpenFilePath() ⇒ string

Returns the path of the currently open file or null if there isn't one open

Kind: global function

setInstantSearchDisabled(disable)

enable/disable instant search

Kind: global function

ParamTypeDescription
disablebooleantrue to disable web worker based search

isInstantSearchDisabled() ⇒ boolean

if instant search is disabled, this will return true we can only do instant search through worker

Kind: global function

isWorkerSearchInProgress() ⇒ Boolean

check if a search is progressing in worker

Kind: global function
Returns: Boolean - true if search is processing in worker

notifyFileFiltersChanged()

Raises an event when the file filters applied to a search changes

Kind: global function

notifySearchScopeChanged()

Raises an event when the search scope changes[say search in a subdirectory in the project]

Kind: global function

notifyWorkerSearchStarted()

Notifies that a worker search has started so that we FindUtils can figure out if any outstanding worker search requests are pending

Kind: global function

notifyWorkerSearchFinished()

Notifies that a worker search has finished so that we FindUtils can figure out if any outstanding worker search requests are pending

Kind: global function

notifyIndexingStarted()

Notifies that a worker has started indexing the files

Kind: global function

notifyIndexingProgress()

Notifies that a worker has started indexing the files

Kind: global function

notifyIndexingFinished()

Notifies that a worker has finished indexing the files

Kind: global function

isIndexingInProgress() ⇒ boolean

Return true if indexing is in progress in worker

Kind: global function
Returns: boolean - true if files are being indexed in worker

setCollapseResults(collapse)

Set if we need to collapse all results in the results pane

Kind: global function

ParamTypeDescription
collapsebooleantrue to collapse

isCollapsedResults() ⇒ boolean

check if results should be collapsed

Kind: global function
Returns: boolean - true if results should be collapsed