@@ -202,7 +202,7 @@ define(function (require, exports, module) {
202202 // If self editor is visible, close all dropdowns on scroll.
203203 // (We don't want to do self if we're just scrolling in a non-visible editor
204204 // in response to some document change event.)
205- if ( self . isFullyVisible ( ) ) {
205+ if ( ! self . _shouldNotDismissPopupsOnScroll && self . isFullyVisible ( ) ) {
206206 Menus . closeAll ( ) ;
207207 }
208208
@@ -244,6 +244,29 @@ define(function (require, exports, module) {
244244 } ) ;
245245 }
246246
247+ /**
248+ * will not dismiss any popups on scrolling the editor till the given timout
249+ * @param {number } [timeoutMs]
250+ * @private
251+ */
252+ function _dontDismissPopupOnScroll ( timeoutMs = 500 ) {
253+ // eslint-disable-next-line no-invalid-this
254+ const self = this ;
255+ // on live code hints, when the user is selecting code hints using arrow keys, the text in the editor changes.
256+ // If the text that is being changed falls beyond the editor border(Eg: end of a long line that is part occluded
257+ // by live preview panel), then cm will scroll the editor horizontally to show the changed text. On scrolling,
258+ // all popups are usually dismissed(see scroll event handler in this file), but that should happen if we
259+ // are live code hinting. So we do this.
260+ if ( self . _shouldNotDismissPopupsOnScroll ) {
261+ clearTimeout ( self . _shouldNotDismissPopupsOnScroll ) ;
262+ }
263+ self . _shouldNotDismissPopupsOnScroll = setTimeout ( ( ) => {
264+ // we only wait for 500 ms after the user pressed up or down arrow key, after which its any scroll will
265+ // dismiss all popups. This is os that user may scroll the text using mouse which should dismiss popups.
266+ self . _shouldNotDismissPopupsOnScroll = false ;
267+ } , timeoutMs ) ;
268+ }
269+
247270 /**
248271 * add required helpers to editor
249272 * @param Editor
@@ -256,6 +279,7 @@ define(function (require, exports, module) {
256279 Editor . prototype . _handleDocumentDeleted = _handleDocumentDeleted ;
257280 Editor . prototype . _handleDocumentLanguageChanged = _handleDocumentLanguageChanged ;
258281 Editor . prototype . _installEditorListeners = _installEditorListeners ;
282+ Editor . prototype . _dontDismissPopupOnScroll = _dontDismissPopupOnScroll ;
259283 }
260284
261285 exports . addHelpers = addHelpers ;
0 commit comments