Skip to content

Commit

Permalink
v8.2.1
Browse files Browse the repository at this point in the history
  • Loading branch information
rjrodger committed Apr 29, 2024
1 parent 1c48f53 commit ead1bf2
Show file tree
Hide file tree
Showing 2 changed files with 27 additions and 21 deletions.
46 changes: 26 additions & 20 deletions bin/seneca-repl-exec.js
Expand Up @@ -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 = {
Expand Down Expand Up @@ -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)

Expand All @@ -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--
Expand Down
2 changes: 1 addition & 1 deletion 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)",
Expand Down

0 comments on commit ead1bf2

Please sign in to comment.