1
0
mirror of https://github.com/adobe/brackets.git synced 2024-11-20 09:53:00 +01:00

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

This commit is contained in:
Swagatam Mitra 2018-03-28 15:25:06 +05:30 committed by Prashanth Nethi
parent 65c61b0624
commit cec41f4d77
2 changed files with 19 additions and 0 deletions

View File

@ -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"));
}
}
};
@ -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
*

View File

@ -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;