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
path: root/doc
diff options
context:
space:
mode:
authorRuben Bridgewater <ruben@bridgewater.de>2019-12-16 12:22:48 +0300
committerRuben Bridgewater <ruben@bridgewater.de>2019-12-25 13:16:38 +0300
commit9e4349e7972b35c23235dde0f5053f0244abaf0a (patch)
treed9ff7c05b7866ef1dfd5e4ed7333db30efe9a817 /doc
parentca9f12bf83bb2beff831c12b674a94122b7519fe (diff)
repl: implement reverse search
Add a reverse search that works similar to the ZSH one. It is triggered with <ctrl> + r and <ctrl> + s. It skips duplicated history entries and works with multiline statements. Matching entries indicate the search parameter with an underscore and cancelling with <ctrl> + c or escape brings back the original line. Multiple matches in a single history entry work as well and are matched in the order of the current search direction. The cursor is positioned at the current match position of the history entry. Changing the direction immediately checks for the next entry in the expected direction from the current position on. Entries are accepted as soon any button is pressed that doesn't correspond with the reverse search. The behavior is deactivated for simple terminals. They do not support most ANSI escape codes that are necessary for this feature. PR-URL: https://github.com/nodejs/node/pull/31006 Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com> Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com> Reviewed-By: Rich Trott <rtrott@gmail.com>
Diffstat (limited to 'doc')
-rw-r--r--doc/api/repl.md27
1 files changed, 24 insertions, 3 deletions
diff --git a/doc/api/repl.md b/doc/api/repl.md
index 4703022d3b5..625f3c22d24 100644
--- a/doc/api/repl.md
+++ b/doc/api/repl.md
@@ -21,9 +21,11 @@ result. Input and output may be from `stdin` and `stdout`, respectively, or may
be connected to any Node.js [stream][].
Instances of [`repl.REPLServer`][] support automatic completion of inputs,
-simplistic Emacs-style line editing, multi-line inputs, ANSI-styled output,
-saving and restoring current REPL session state, error recovery, and
-customizable evaluation functions.
+completion preview, simplistic Emacs-style line editing, multi-line inputs,
+[ZSH][] like reverse-i-search, ANSI-styled output, saving and restoring current
+REPL session state, error recovery, and customizable evaluation functions.
+Terminals that do not support ANSI-styles and Emacs-style line editing
+automatically fall back to a limited feature set.
### Commands and Special Keys
@@ -232,6 +234,24 @@ undefined
undefined
```
+### Reverse-i-search
+<!-- YAML
+added: REPLACEME
+-->
+
+The REPL supports bi-directional reverse-i-search similar to [ZSH][]. It is
+triggered with `<ctrl> + R` to search backwards and `<ctrl> + S` to search
+forwards.
+
+Duplicated history entires will be skipped.
+
+Entries are accepted as soon as any button is pressed that doesn't correspond
+with the reverse search. Cancelling is possible by pressing `escape` or
+`<ctrl> + C`.
+
+Changing the direction immediately searches for the next entry in the expected
+direction from the current position on.
+
### Custom Evaluation Functions
When a new [`repl.REPLServer`][] is created, a custom evaluation function may be
@@ -695,6 +715,7 @@ a `net.Server` and `net.Socket` instance, see:
For an example of running a REPL instance over [curl(1)][], see:
<https://gist.github.com/TooTallNate/2053342>.
+[ZSH]: https://en.wikipedia.org/wiki/Z_shell
[`'uncaughtException'`]: process.html#process_event_uncaughtexception
[`--experimental-repl-await`]: cli.html#cli_experimental_repl_await
[`ERR_DOMAIN_CANNOT_SET_UNCAUGHT_EXCEPTION_CAPTURE`]: errors.html#errors_err_domain_cannot_set_uncaught_exception_capture