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

Commit cec41f4

Browse files
swmitranethip
authored andcommitted
Add 'onHighlight' optional event callback mechanism for better extensibility features in hint providers (#14140)
1 parent 65c61b0 commit cec41f4

2 files changed

Lines changed: 19 additions & 0 deletions

File tree

src/editor/CodeHintList.js

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -150,6 +150,10 @@ define(function (require, exports, module) {
150150

151151
$item.find("a").addClass("highlight");
152152
ViewUtils.scrollElementIntoView($view, $item, false);
153+
154+
if (this.handleHighlight) {
155+
this.handleHighlight($item.find("a"));
156+
}
153157
}
154158
};
155159

@@ -544,6 +548,15 @@ define(function (require, exports, module) {
544548
this.handleSelect = callback;
545549
};
546550

551+
/**
552+
* Set the hint list highlight callback function
553+
*
554+
* @param {Function} callback
555+
*/
556+
CodeHintList.prototype.onHighlight = function (callback) {
557+
this.handleHighlight = callback;
558+
};
559+
547560
/**
548561
* Set the hint list closure callback function
549562
*

src/editor/CodeHintManager.js

Lines changed: 6 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -507,6 +507,12 @@ define(function (require, exports, module) {
507507

508508
sessionEditor = editor;
509509
hintList = new CodeHintList(sessionEditor, insertHintOnTab, maxCodeHints);
510+
hintList.onHighlight(function ($hint) {
511+
// If the current hint provider listening for hint item highlight change
512+
if (sessionProvider.onHighlight) {
513+
sessionProvider.onHighlight($hint);
514+
}
515+
});
510516
hintList.onSelect(function (hint) {
511517
var restart = sessionProvider.insertHint(hint),
512518
previousEditor = sessionEditor;

0 commit comments

Comments
 (0)