Merge pull request #2889 from haslinghuis/fix_cli_autocomplete

Fix autocomplete
10.8-maintenance
Ivan Efimov 2022-04-12 18:56:13 -05:00 committed by GitHub
commit b2a33deec8
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
1 changed files with 20 additions and 11 deletions

View File

@ -289,23 +289,32 @@ CliAutoComplete._initTextcomplete = function() {
* Then add `mousemove` handler. If the mouse moves we consider that mouse interaction * Then add `mousemove` handler. If the mouse moves we consider that mouse interaction
* is desired so we reenable the `mouseover` handler * is desired so we reenable the `mouseover` handler
*/ */
const textCompleteDropDownElement = $('.textcomplete-dropdown');
if (!savedMouseoverItemHandler) { if (!savedMouseoverItemHandler) {
// save the original 'mouseover' handeler // save the original 'mouseover' handeler
savedMouseoverItemHandler = $._data($('.textcomplete-dropdown')[0], 'events').mouseover[0].handler; try {
} savedMouseoverItemHandler = $._data(textCompleteDropDownElement[0], 'events').mouseover[0].handler;
} catch (error) {
console.log(error);
}
$('.textcomplete-dropdown') if (savedMouseoverItemHandler) {
.off('mouseover') // initially disable it textCompleteDropDownElement
.off('mousemove') // avoid `mousemove` accumulation if previous show did not trigger `mousemove` .off('mouseover') // initially disable it
.on('mousemove', '.textcomplete-item', function(e) { .off('mousemove') // avoid `mousemove` accumulation if previous show did not trigger `mousemove`
// the mouse has moved so reenable `mouseover` .on('mousemove', '.textcomplete-item', function(e) {
$(this).parent() // the mouse has moved so reenable `mouseover`
$(this).parent()
.off('mousemove') .off('mousemove')
.on('mouseover', '.textcomplete-item', savedMouseoverItemHandler); .on('mouseover', '.textcomplete-item', savedMouseoverItemHandler);
// trigger the mouseover handler to select the item under the cursor // trigger the mouseover handler to select the item under the cursor
savedMouseoverItemHandler(e); savedMouseoverItemHandler(e);
}); });
}
}
}); });
// textcomplete autocomplete strategies // textcomplete autocomplete strategies