From cec41f4d77c7254ed49885a18c0b6a13d65ee8d4 Mon Sep 17 00:00:00 2001 From: Swagatam Mitra Date: Wed, 28 Mar 2018 15:25:06 +0530 Subject: [PATCH] Add 'onHighlight' optional event callback mechanism for better extensibility features in hint providers (#14140) --- src/editor/CodeHintList.js | 13 +++++++++++++ src/editor/CodeHintManager.js | 6 ++++++ 2 files changed, 19 insertions(+) diff --git a/src/editor/CodeHintList.js b/src/editor/CodeHintList.js index d9561a453f2..964e1ed447c 100644 --- a/src/editor/CodeHintList.js +++ b/src/editor/CodeHintList.js @@ -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 * diff --git a/src/editor/CodeHintManager.js b/src/editor/CodeHintManager.js index 1dea3bf8120..8a2cdf28e69 100644 --- a/src/editor/CodeHintManager.js +++ b/src/editor/CodeHintManager.js @@ -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;