Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/nodejs/node.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-12-27 17:32:39 +0300
committerRuben Bridgewater <ruben@bridgewater.de>2020-01-10 11:11:47 +0300
commit625a0ec5e18f85ee7b1589f308d2c93116484007 (patch)
tree353b4a59c9d7dab4aa60f49975cab6e566ebb92f /lib/internal/repl
parent07c55bb81fcf05a070168e570b618461ad4a847e (diff)
readline,repl: add substring based history search
This improves the current history search feature by adding substring based history search similar to ZSH. In case the `UP` or `DOWN` buttons are pressed after writing a few characters, the start string up to the current cursor is used to search the history. All other history features work exactly as they used to. PR-URL: https://github.com/nodejs/node/pull/31112 Fixes: https://github.com/nodejs/node/issues/28437 Reviewed-By: Michaƫl Zasso <targos@protonmail.com> Reviewed-By: James M Snell <jasnell@gmail.com>
Diffstat (limited to 'lib/internal/repl')
-rw-r--r--lib/internal/repl/utils.js2
1 files changed, 2 insertions, 0 deletions
diff --git a/lib/internal/repl/utils.js b/lib/internal/repl/utils.js
index 6eee8d3c273..1b9a0209f89 100644
--- a/lib/internal/repl/utils.js
+++ b/lib/internal/repl/utils.js
@@ -33,6 +33,7 @@ const {
const {
commonPrefix,
getStringWidth,
+ kSubstringSearch,
} = require('internal/readline/utils');
const { inspect } = require('util');
@@ -646,6 +647,7 @@ function setupReverseSearch(repl) {
typeof string !== 'string' ||
string === '') {
reset();
+ repl[kSubstringSearch] = '';
} else {
reset(`${input}${string}`);
search();