mirror of
https://github.com/adobe/brackets.git
synced 2024-11-20 18:02:54 +01:00
Add option for first highlight index in Quick Open and Search History (#13444)
* Fixed #13437 * minor change * Passed first highlight index as paramater to QuickSearchField * Added jsdocs
This commit is contained in:
parent
f4dd55c203
commit
038bcb6a51
@ -444,6 +444,7 @@ define(function (require, exports, module) {
|
||||
this.searchField = new QuickSearchField(searchFieldInput, {
|
||||
verticalAdjust: searchFieldInput.offset().top > 0 ? 0 : this._modalBar.getRoot().outerHeight(),
|
||||
maxResults: 20,
|
||||
firstHighlightIndex: null,
|
||||
resultProvider: function (query) {
|
||||
var asyncResult = new $.Deferred();
|
||||
asyncResult.resolve(PreferencesManager.getViewState("searchHistory"));
|
||||
|
@ -652,6 +652,7 @@ define(function (require, exports, module) {
|
||||
|
||||
this.searchField = new QuickSearchField(this.$searchField, {
|
||||
maxResults: 20,
|
||||
firstHighlightIndex: 0,
|
||||
verticalAdjust: this.modalBar.getRoot().outerHeight(),
|
||||
resultProvider: this._filterCallback,
|
||||
formatter: this._resultsFormatterCallback,
|
||||
|
@ -73,6 +73,8 @@ define(function (require, exports, module) {
|
||||
* Number of pixels to position the popup below where $input is when constructor is called. Useful
|
||||
* if UI is going to animate position after construction, but QuickSearchField may receive input
|
||||
* before the animation is done.
|
||||
* @param {?number} options.firstHighlightIndex
|
||||
* Index of the result that is highlighted by default. null to not highlight any result.
|
||||
*/
|
||||
function QuickSearchField($input, options) {
|
||||
this.$input = $input;
|
||||
@ -91,6 +93,9 @@ define(function (require, exports, module) {
|
||||
|
||||
$input.on("input", this._handleInput);
|
||||
$input.on("keydown", this._handleKeyDown);
|
||||
|
||||
// For search History this value is set to null
|
||||
this._firstHighlightIndex = options.firstHighlightIndex;
|
||||
|
||||
this._dropdownTop = $input.offset().top + $input.height() + (options.verticalAdjust || 0);
|
||||
}
|
||||
@ -277,7 +282,11 @@ define(function (require, exports, module) {
|
||||
QuickSearchField.prototype._render = function (results, query) {
|
||||
this._displayedQuery = query;
|
||||
this._displayedResults = results;
|
||||
this._highlightIndex = null;
|
||||
if (this._firstHighlightIndex >= 0) {
|
||||
this._highlightIndex = this._firstHighlightIndex;
|
||||
} else {
|
||||
this._highlightIndex = null;
|
||||
}
|
||||
// TODO: fixup to match prev value's item if possible?
|
||||
|
||||
if (results.error || results.length === 0) {
|
||||
|
@ -49,7 +49,8 @@ define(function (require, exports, module) {
|
||||
formatter: function (item) { return "<li>" + item + "</li>"; },
|
||||
resultProvider: function (query) { return provider(query); },
|
||||
onCommit: function (item, query) { return onCommit(item, query); },
|
||||
onHighlight: jasmine.createSpy()
|
||||
onHighlight: jasmine.createSpy(),
|
||||
firstHighlightIndex: 0
|
||||
};
|
||||
searchField = new QuickSearchField($mockInput, options);
|
||||
|
||||
|
Loading…
Reference in New Issue
Block a user