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

Commit

Permalink
Quick Open plugins can include matcherOptions to set StringMatch options
Browse files Browse the repository at this point in the history
  • Loading branch information
dangoor committed May 14, 2013
1 parent b6792bd commit 13a0077
Showing 1 changed file with 8 additions and 3 deletions.
11 changes: 8 additions & 3 deletions src/search/QuickOpen.js
Original file line number Diff line number Diff line change
Expand Up @@ -98,7 +98,7 @@ define(function (require, exports, module) {
/**
* Defines API for new QuickOpen plug-ins
*/
function QuickOpenPlugin(name, languageIds, done, search, match, itemFocus, itemSelect, resultsFormatter) {
function QuickOpenPlugin(name, languageIds, done, search, match, itemFocus, itemSelect, resultsFormatter, matcherOptions) {
this.name = name;
this.languageIds = languageIds;
this.done = done;
Expand All @@ -107,6 +107,7 @@ define(function (require, exports, module) {
this.itemFocus = itemFocus;
this.itemSelect = itemSelect;
this.resultsFormatter = resultsFormatter;
this.matcherOptions = matcherOptions;
}

/**
Expand All @@ -120,6 +121,7 @@ define(function (require, exports, module) {
* itemFocus: function(?SearchResult|string),
* itemSelect: funciton(?SearchResult|string),
* resultsFormatter: ?function(SearchResult|string, string):string
* matcherOptions: Object
* } pluginDef
*
* Parameter Documentation:
Expand All @@ -137,6 +139,8 @@ define(function (require, exports, module) {
* The selected search result item (as returned by search()) is passed as an argument.
* resultFormatter - takes a query string and an item string and returns
* a <LI> item to insert into the displayed search results. If null, default is provided.
* matcherOptions - options to pass along to the StringMatcher (see StringMatch.StringMatcher
* for available options)
*
* If itemFocus() makes changes to the current document or cursor/scroll position and then the user
* cancels Quick Open (via Esc), those changes are automatically reverted.
Expand All @@ -159,7 +163,8 @@ define(function (require, exports, module) {
pluginDef.match,
pluginDef.itemFocus,
pluginDef.itemSelect,
pluginDef.resultsFormatter
pluginDef.resultsFormatter,
pluginDef.matcherOptions
));
}

Expand Down Expand Up @@ -554,7 +559,7 @@ define(function (require, exports, module) {
// Look up the StringMatcher for this plugin.
var matcher = this._matchers[currentPlugin.name];
if (!matcher) {
matcher = new StringMatch.StringMatcher();
matcher = new StringMatch.StringMatcher(plugin.matcherOptions);
this._matchers[currentPlugin.name] = matcher;
}
return plugin.search(query, matcher);
Expand Down

0 comments on commit 13a0077

Please sign in to comment.