diff --git a/bin/seneca-repl-exec.js b/bin/seneca-repl-exec.js index f83cdc4..33209ae 100755 --- a/bin/seneca-repl-exec.js +++ b/bin/seneca-repl-exec.js @@ -17,7 +17,7 @@ const { minify_sync } = require('terser') const JP = (arg) => JSON.parse(arg) const JS = (a0, a1) => JSON.stringify(a0, a1) -const makesearchprompt = search => 'search: [' + search + '] ' +const makesearchprompt = (search) => 'search: [' + search + '] ' const DISTANCE_TO_SEARCH_BOX = 2 const state = { @@ -318,28 +318,29 @@ function operate(spec, done) { if ('search' === state.connection.mode) { if (spec.name === 'backspace') { state.connection.search = state.connection.search.slice(0, -1) - } else if (spec.ctrl && spec.name === 'u') { - state.connection.search = '' - } else if (key) { // NOTE: sometimes `key` is undefined (e.g. when an arrow-key is pressed) - let cc = key.charCodeAt(0) - if (31 < cc || 8 === cc) { - if (127 === cc || 8 === cc) { - // state.connection.search = - // state.connection.search.substring(0,state.connection.search.length-1) - // state.connection.offset = 0 - } else { - state.connection.search += key - } - } else if ('r' == spec.name && spec.ctrl) { - state.connection.offset++ - } - } + } else if (spec.ctrl && spec.name === 'u') { + state.connection.search = '' + } else if (key) { + // NOTE: sometimes `key` is undefined (e.g. when an arrow-key is pressed) + let cc = key.charCodeAt(0) + if (31 < cc || 8 === cc) { + if (127 === cc || 8 === cc) { + // state.connection.search = + // state.connection.search.substring(0,state.connection.search.length-1) + // state.connection.offset = 0 + } else { + state.connection.search += key + } + } else if ('r' == spec.name && spec.ctrl) { + state.connection.offset++ + } + } let search = state.connection.search Readline.cursorTo(process.stdout, 0, () => { Readline.clearLine(process.stdout, 0) - state.connection.readline.line = '' + state.connection.readline.line = '' // state.connection.readline.write(searchprompt) @@ -349,9 +350,14 @@ function operate(spec, done) { for (let i = 0; i < history.length; i++) { if (history[i].includes(search)) { if (0 === offset) { - state.connection.readline.write(makesearchprompt(search) + history[i]) + state.connection.readline.write( + makesearchprompt(search) + history[i], + ) state.connection.found = history[i] - Readline.moveCursor(process.stdout, -(DISTANCE_TO_SEARCH_BOX + history[i].length)) + Readline.moveCursor( + process.stdout, + -(DISTANCE_TO_SEARCH_BOX + history[i].length), + ) break } else { offset-- diff --git a/package.json b/package.json index ab52963..7272426 100644 --- a/package.json +++ b/package.json @@ -1,7 +1,7 @@ { "name": "@seneca/repl", "description": "Provides a client and server REPL for Seneca microservice systems.", - "version": "8.2.0", + "version": "8.2.1", "main": "dist/repl.js", "license": "MIT", "author": "Richard Rodger (https://github.com/rjrodger)",