diff options
author | Ruben Bridgewater <ruben@bridgewater.de> | 2019-12-16 12:22:48 +0300 |
---|---|---|
committer | Ruben Bridgewater <ruben@bridgewater.de> | 2020-01-03 18:12:15 +0300 |
commit | 09ca8be1f2edc4f27e56297859d666a0ff3dddd3 (patch) | |
tree | 17544574336ffedc0bfb409edeff98ab9a05b8a0 /doc | |
parent | 925dd8e7f9d7842f9e695c147e43cca3b8c61154 (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.md | 27 |
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 |