| 188 | * @param {Number} index - of the selected result item |
| 189 | */ |
| 190 | const select = (ctx, event, index) => { |
| 191 | // Check if cursor within list range |
| 192 | index = index >= 0 ? index : ctx.cursor; |
| 193 | |
| 194 | // Prevent empty selection |
| 195 | if (index < 0) return; |
| 196 | |
| 197 | // Prepare Selection data feedback object |
| 198 | ctx.feedback.event = event; |
| 199 | feedback(ctx, index); |
| 200 | |
| 201 | /** |
| 202 | * @emit {selection} event on result item selection |
| 203 | **/ |
| 204 | eventEmitter("selection", ctx); |
| 205 | |
| 206 | close(ctx); |
| 207 | }; |
| 208 | |
| 209 | /** |
| 210 | * Click selection handler |