From bd3a482c1368d1571c00adf1ba6113712dfdf2f9 Mon Sep 17 00:00:00 2001 From: Max Bykov Date: Wed, 31 Aug 2022 21:09:18 +0300 Subject: [PATCH 1/2] hotfix --- src/controllers/listController.js | 22 +++++++++++++--------- 1 file changed, 13 insertions(+), 9 deletions(-) diff --git a/src/controllers/listController.js b/src/controllers/listController.js index 95c9d0e..e98559f 100644 --- a/src/controllers/listController.js +++ b/src/controllers/listController.js @@ -187,23 +187,27 @@ const previous = (ctx) => { * @param {Object} event - of selection * @param {Number} index - of the selected result item */ -const select = (ctx, event, index) => { + const select = (ctx, event, index) => { // Check if cursor within list range index = index >= 0 ? index : ctx.cursor; // Prevent empty selection if (index < 0) return; - // Prepare Selection data feedback object - ctx.feedback.event = event; - feedback(ctx, index); + // Wait for ctx.feedback being fullfilled + start(ctx, ' ').then(() => { - /** - * @emit {selection} event on result item selection - **/ - eventEmitter("selection", ctx); + // Prepare Selection data feedback object + ctx.feedback.event = event; + feedback(ctx, index); - close(ctx); + /** + * @emit {selection} event on result item selection + **/ + eventEmitter("selection", ctx); + + close(ctx); + }); }; /** From 3797f10ea7b3910a86cbfa855327f4534fa16426 Mon Sep 17 00:00:00 2001 From: Max Bykov Date: Thu, 1 Sep 2022 12:57:48 +0300 Subject: [PATCH 2/2] move up to extend' method --- src/controllers/listController.js | 22 +++++++++------------- src/services/extend.js | 5 ++++- 2 files changed, 13 insertions(+), 14 deletions(-) diff --git a/src/controllers/listController.js b/src/controllers/listController.js index e98559f..95c9d0e 100644 --- a/src/controllers/listController.js +++ b/src/controllers/listController.js @@ -187,27 +187,23 @@ const previous = (ctx) => { * @param {Object} event - of selection * @param {Number} index - of the selected result item */ - const select = (ctx, event, index) => { +const select = (ctx, event, index) => { // Check if cursor within list range index = index >= 0 ? index : ctx.cursor; // Prevent empty selection if (index < 0) return; - // Wait for ctx.feedback being fullfilled - start(ctx, ' ').then(() => { + // Prepare Selection data feedback object + ctx.feedback.event = event; + feedback(ctx, index); - // Prepare Selection data feedback object - ctx.feedback.event = event; - feedback(ctx, index); - - /** - * @emit {selection} event on result item selection - **/ - eventEmitter("selection", ctx); + /** + * @emit {selection} event on result item selection + **/ + eventEmitter("selection", ctx); - close(ctx); - }); + close(ctx); }; /** diff --git a/src/services/extend.js b/src/services/extend.js index 98945c9..c9afa9c 100644 --- a/src/services/extend.js +++ b/src/services/extend.js @@ -76,7 +76,10 @@ export default function (autoComplete) { * */ prototype.select = function (index) { - select(this, null, index); + // Wait for 'ctx.feedback' being fullfilled + start(this, ' ').then(() => { + select(this, null, index); + }); }; /**