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

Commit

Permalink
Add 'onHighlight' optional event callback mechanism for better extens…
Browse files Browse the repository at this point in the history
…ibility features in hint providers (#14140)
  • Loading branch information
swmitra authored and nethip committed Mar 28, 2018
1 parent 65c61b0 commit cec41f4
Show file tree
Hide file tree
Showing 2 changed files with 19 additions and 0 deletions.
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

0 comments on commit cec41f4

Please sign in to comment.