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

Add 'onHighlight' optional event callback mechanism for better extensibility features in hint providers #14140

Merged
merged 1 commit into from
Mar 28, 2018
Merged
Show file tree
Hide file tree
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
13 changes: 13 additions & 0 deletions src/editor/CodeHintList.js
Original file line number Diff line number Diff line change
Expand Up @@ -150,6 +150,10 @@ define(function (require, exports, module) {

$item.find("a").addClass("highlight");
ViewUtils.scrollElementIntoView($view, $item, false);

if (this.handleHighlight) {
this.handleHighlight($item.find("a"));
}
}
};

Expand Down Expand Up @@ -544,6 +548,15 @@ define(function (require, exports, module) {
this.handleSelect = callback;
};

/**
* Set the hint list highlight callback function
*
* @param {Function} callback
*/
CodeHintList.prototype.onHighlight = function (callback) {
this.handleHighlight = callback;
};

/**
* Set the hint list closure callback function
*
Expand Down
6 changes: 6 additions & 0 deletions src/editor/CodeHintManager.js
Original file line number Diff line number Diff line change
Expand Up @@ -507,6 +507,12 @@ define(function (require, exports, module) {

sessionEditor = editor;
hintList = new CodeHintList(sessionEditor, insertHintOnTab, maxCodeHints);
hintList.onHighlight(function ($hint) {
// If the current hint provider listening for hint item highlight change
if (sessionProvider.onHighlight) {
sessionProvider.onHighlight($hint);
}
});
hintList.onSelect(function (hint) {
var restart = sessionProvider.insertHint(hint),
previousEditor = sessionEditor;
Expand Down