Dario Piotrowicz
200fe9e7f4
repl: move completion logic to internal module
...
PR-URL: https://github.com/nodejs/node/pull/59889
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Joyee Cheung <joyeec9h3@gmail.com >
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
2025-10-08 07:37:22 +00:00
René
196f5466af
lib: revert to using default derived class constructors
...
PR-URL: https://github.com/nodejs/node/pull/59650
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-08-30 14:28:10 +00:00
Xuguang Mei
ebd2da6d11
repl: add isValidParentheses check before wrap input
...
PR-URL: https://github.com/nodejs/node/pull/59607
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2025-08-27 17:32:01 +00:00
Giovanni Bucci
4a4aa58fa4
repl: add support for multiline history
...
PR-URL: https://github.com/nodejs/node/pull/57400
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Jordan Harband <ljharb@gmail.com >
2025-04-13 11:58:01 +00:00
Dario Piotrowicz
922ce9d236
debugger: fix behavior of plain object exec in debugger repl
...
Co-authored-by: Xuguang Mei <meixuguang@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/57498
Fixes: https://github.com/nodejs/node/issues/46808
Reviewed-By: Yagiz Nizipli <yagiz@nizipli.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Xuguang Mei <meixuguang@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2025-03-18 19:30:31 +00:00
Gürgün Dayıoğlu
8ed50bcbe5
lib: remove startsWith/endsWith primordials for char checks
...
PR-URL: https://github.com/nodejs/node/pull/55407
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: Mattias Buelens <mattias@buelens.com >
Reviewed-By: Ethan Arrowood <ethan@arrowood.dev >
2024-10-19 10:18:10 +00:00
Aviv Keller
c6d20a034d
repl: catch \v and \r in new-line detection
...
PR-URL: https://github.com/nodejs/node/pull/54512
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
Reviewed-By: LiviaMedeiros <livia@cirno.name >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
2024-09-25 08:51:11 +00:00
linkgoron
12232946c0
repl: fix disruptive autocomplete without inspector
...
Fix an issue where the autocomplete wrongly autocompletes
a value from a correct value to an undefined value when `node`
is built without an inspector by disabling the preview view.
fixes: https://github.com/nodejs/node/issues/40635
PR-URL: https://github.com/nodejs/node/pull/40661
Fixes: https://github.com/nodejs/node/issues/40635
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
2024-05-12 11:15:25 +02:00
Xuguang Mei
2566400aa2
repl: preserve preview on ESCAPE key press
...
Fix : #46876
PR-URL: https://github.com/nodejs/node/pull/46878
Fixes: https://github.com/nodejs/node/issues/46876
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2023-03-16 03:24:23 +00:00
Duy Mac Van
d0608c2b4d
repl: remove lastInputPreview conditional check
...
PR-URL: https://github.com/nodejs/node/pull/46857
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Kohei Ueno <kohei.ueno119@gmail.com >
2023-03-01 14:28:31 +00:00
Antoine du Hamel
e4e8421c25
repl: add trailing commas in source files
...
PR-URL: https://github.com/nodejs/node/pull/46757
Reviewed-By: Deokjin Kim <deokjin81.kim@gmail.com >
Reviewed-By: Qingyu Deng <i@ayase-lab.com >
Reviewed-By: Moshe Atlow <moshe@atlow.co.il >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2023-02-24 09:43:27 +01:00
Antoine du Hamel
fe514bf960
lib: enforce use of trailing commas for functions
...
PR-URL: https://github.com/nodejs/node/pull/46629
Reviewed-By: Jacob Smith <jacob@frende.me >
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Chengzhong Wu <legendecas@gmail.com >
Reviewed-By: Mohammed Keyvanzadeh <mohammadkeyvanzade94@gmail.com >
2023-02-14 18:45:16 +01:00
Antoine du Hamel
a055337a02
lib: refactor to avoid unsafe regex primordials
...
PR-URL: https://github.com/nodejs/node/pull/43475
Reviewed-By: Geoffrey Booth <webadmin@geoffreybooth.com >
Reviewed-By: Stephen Belanger <admin@stephenbelanger.com >
2022-06-27 17:16:06 +02:00
Rich Trott
55ceaec111
tools,benchmark,lib,test: enable no-case-declarations lint rule
...
PR-URL: https://github.com/nodejs/node/pull/41385
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Tobias Nießen <tniessen@tnie.de >
Reviewed-By: Tierney Cyren <hello@bnb.im >
Reviewed-By: Ricky Zhou <0x19951125@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
2022-01-05 07:42:19 -08:00
Michaël Zasso
189d584244
deps: update Acorn to v8.4.1
...
We can remove the Acorn plugins as their features are now supported
by default.
PR-URL: https://github.com/nodejs/node/pull/39166
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Guy Bedford <guybedford@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Jiawen Geng <technicalcute@gmail.com >
Reviewed-By: Anna Henningsen <anna@addaleax.net >
2021-06-29 17:20:45 +02:00
Antoine du Hamel
54dfdbcccf
readline: move utilities to internal modules
...
PR-URL: https://github.com/nodejs/node/pull/38466
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2021-05-02 09:20:18 +02:00
eladkeyshawn
d6669645c0
repl: fix declaring a variable with the name util
...
The REPL no longer relies on `util` being a reference to the `util` core
module. It still relies on `globalThis` refering to the global object,
but no longer emits warnings when it's overwritten by the user.
PR-URL: https://github.com/nodejs/node/pull/38141
Fixes: https://github.com/nodejs/node/issues/38139
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
2021-04-18 16:12:41 +02:00
Antoine du Hamel
708f049471
repl: refactor to avoid unsafe array iteration
...
PR-URL: https://github.com/nodejs/node/pull/37345
Reviewed-By: Darshan Sen <raisinten@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-02-15 23:06:35 +01:00
raisinten
9a18bf2f8c
repl: refactor to avoid unsafe array iteration
...
PR-URL: https://github.com/nodejs/node/pull/36663
Reviewed-By: Antoine du Hamel <duhamelantoine1995@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2021-01-18 13:29:43 -08:00
Antoine du Hamel
bd6f2303f4
lib: add primordials.SafeStringIterator
...
PR-URL: https://github.com/nodejs/node/pull/36526
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-25 18:11:23 +00:00
Antoine du Hamel
825029ec59
repl: refactor to use more primordials
...
PR-URL: https://github.com/nodejs/node/pull/36264
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-12-02 20:22:03 +00:00
Mattias Runge-Broberg
60a97c0b42
readline: add getPrompt to get the current prompt
...
Since there is a setPrompt() there should be a getPrompt().
There are use-cases where it is needed to know what the
current prompt is. Adding a getPrompt() negates the need
to store the set prompt externally or read the internal
_prompt which would be bad practice.
Co-authored-by: Colin Ihrig <cjihrig@gmail.com >
PR-URL: https://github.com/nodejs/node/pull/33675
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: Benjamin Gruenbaum <benjamingr@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Juan José Arboleda <soyjuanarbol@gmail.com >
2020-11-10 19:46:51 +00:00
Michaël Zasso
0ddd69e2ed
assert,repl: enable ecmaVersion 2021 in acorn parser
...
This adds support for the new logical assignment operators.
PR-URL: https://github.com/nodejs/node/pull/35827
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Jiawen Geng <technicalcute@gmail.com >
Reviewed-By: Richard Lau <rlau@redhat.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Gus Caplan <me@gus.host >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2020-10-30 14:52:28 +00:00
Michaël Zasso
16b2bc01eb
deps: update acorn to v8.0.4
...
This adds support for nullish coalescing, optional chaining and
numeric separators.
The acorn-numeric-separator plugin can be removed.
PR-URL: https://github.com/nodejs/node/pull/35791
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Daijiro Wachi <daijiro.wachi@gmail.com >
Reviewed-By: Matteo Collina <matteo.collina@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Shelley Vohr <codebytere@gmail.com >
Reviewed-By: Jiawen Geng <technicalcute@gmail.com >
2020-10-27 03:26:56 +00:00
Brian White
c24b74a7ab
lib: improve debuglog() performance
...
PR-URL: https://github.com/nodejs/node/pull/32260
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-05-30 17:24:43 -04:00
Ruben Bridgewater
b38d26a168
repl: show reference errors during preview
...
This aligns the behavior with the one in the Firefox console.
It will visualize ReferenceErrors in case the input has no possible
completion and no buffered input. That way typos can already be
highlighted before being evaluated.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33282
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-05-15 01:48:13 +02:00
Ruben Bridgewater
80913e655f
repl: improve repl preview
...
This aligns the REPL preview with the one used in the Chrome
DevTools console. It will now preview the output for the input
including the completion suffix as input. When pressing enter while
previewing such data, it will automatically insert the suffix
before evaluating the input. When pressing escape, that behavior
is deactivated until the input is changed.
Signed-off-by: Ruben Bridgewater <ruben@bridgewater.de >
PR-URL: https://github.com/nodejs/node/pull/33282
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2020-05-15 01:48:08 +02:00
Ruben Bridgewater
9c18ff6440
repl: align preview with the actual executed code
...
This adds preview output for input that may not be wrapped.
PR-URL: https://github.com/nodejs/node/pull/32154
Reviewed-By: Shelley Vohr <codebytere@gmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-03-13 09:58:12 +01:00
Ruben Bridgewater
8fb5fe28a4
util: improve unicode support
...
The array grouping function relies on the width of the characters.
It was not calculated correct so far, since it used the string
length instead.
This improves the unicode output by calculating the mono-spaced
font width (other fonts might differ).
PR-URL: https://github.com/nodejs/node/pull/31319
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Steven R Loomis <srloomis@us.ibm.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
2020-01-22 15:33:03 +01:00
Ruben Bridgewater
c3b702f9b4
repl: do not preview while pasting code
...
This makes sure no previews are triggered while pasting code. The
very last character is allowed to trigger the preview. The output
should be completely identical to the user.
PR-URL: https://github.com/nodejs/node/pull/31315
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Minwoo Jung <nodecorelab@gmail.com >
2020-01-13 08:59:45 +01:00
Ruben Bridgewater
af5ddf2123
repl: fix preview cursor position
...
The cusor position was off in case the preview was exactly as long
as the current terminal was wide.
PR-URL: https://github.com/nodejs/node/pull/31293
Fixes: https://github.com/nodejs/node/issues/31291
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-01-12 20:43:12 +01:00
Ruben Bridgewater
fe058188a1
repl,readline: clean up code
...
This simplifies code that was more complicated than it had to be
and removes code that should never be reached.
PR-URL: https://github.com/nodejs/node/pull/31288
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2020-01-11 14:06:45 -08:00
Ruben Bridgewater
84c3b87494
test: add repl tests to verify unicode support in previews
...
This also adds a test to verify that changed writer options also
change the preview output depending on the options.
PR-URL: https://github.com/nodejs/node/pull/31112
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-01-10 09:11:57 +01:00
Ruben Bridgewater
5235394e66
repl: activate previews for lines exceeding the terminal columns
...
This improves the completion previews by activating them for lines
that exceed the current terminal columns.
As a drive-by fix it also simplifies some statements.
PR-URL: https://github.com/nodejs/node/pull/31112
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-01-10 09:11:56 +01:00
Ruben Bridgewater
625a0ec5e1
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 >
2020-01-10 09:11:47 +01:00
Ruben Bridgewater
07c55bb81f
repl: improve preview length calculation
...
The preview had an off by one error in case colors where deactivated
and did not take fullwidth unicode characters into account when
displaying the preview.
PR-URL: https://github.com/nodejs/node/pull/31112
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: James M Snell <jasnell@gmail.com >
2020-01-10 09:11:46 +01:00
Sebastien Ahkrin
256c9a43f4
lib: replace Set global by the primordials
...
PR-URL: https://github.com/nodejs/node/pull/31154
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: James M Snell <jasnell@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: David Carlier <devnexen@gmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
2020-01-04 12:41:09 -08:00
cjihrig
befff8fa60
repl: use public getCursorPos()
...
_getCursorPos() recently became public API. This commit updates
the remaining uses of _getCursorPos() to use the public API.
PR-URL: https://github.com/nodejs/node/pull/31091
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
2019-12-25 20:12:23 -05:00
Ruben Bridgewater
9e4349e797
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 >
2019-12-25 11:16:38 +01:00
Ruben Bridgewater
ca9f12bf83
repl: fix preview of lines that exceed the terminal columns
...
This adds support for very long input lines to still display the
input preview correct.
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 >
2019-12-25 11:15:03 +01:00
Ruben Bridgewater
2986068c5a
repl: fix preview bug in case of long lines
...
This addresses an issue that is caused by lines that exceed the
current window columns. That would cause the preview to confuse the
REPL. This is meant as hot fix. The preview should be able to handle
these cases appropriately as well later on.
PR-URL: https://github.com/nodejs/node/pull/30907
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2019-12-15 16:26:35 +01:00
Ruben Bridgewater
21ecaa47ee
repl: add completion preview
...
This improves the already existing preview functionality by also
checking for the input completion. In case there's only a single
completion, it will automatically be visible to the user in grey.
If colors are deactivated, it will be visible as comment.
This also changes some keys by automatically accepting the preview
by moving the cursor behind the current input end.
PR-URL: https://github.com/nodejs/node/pull/30907
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Rich Trott <rtrott@gmail.com >
2019-12-15 16:26:35 +01:00
Ruben Bridgewater
6bdf8d1060
repl: support previews by eager evaluating input
...
This adds input previews by using the inspectors eager evaluation
functionality.
It is implemented as additional line that is not counted towards
the actual input. In case no colors are supported, it will be visible
as comment. Otherwise it's grey.
It will be triggered on any line change. It is heavily tested against
edge cases and adheres to "dumb" terminals (previews are deactived
in that case).
PR-URL: https://github.com/nodejs/node/pull/30811
Fixes: https://github.com/nodejs/node/issues/20977
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com >
Reviewed-By: Anto Aravinth <anto.aravinth.cse@gmail.com >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2019-12-10 00:23:23 +01:00
Sebastien Ahkrin
eac3f0adc4
lib: replace Symbol global by the primordials Symbol
...
PR-URL: https://github.com/nodejs/node/pull/30737
Reviewed-By: Michaël Zasso <targos@protonmail.com >
Reviewed-By: Trivikram Kamat <trivikr.dev@gmail.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Luigi Pinca <luigipinca@gmail.com >
2019-12-08 13:38:58 +01:00
Michaël Zasso
60a207f5f2
deps: update acorn to 6.2.0
...
Includes support for bigint syntax so we can remove the acorn-bigint
plugin.
PR-URL: https://github.com/nodejs/node/pull/28649
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de >
Reviewed-By: Richard Lau <riclau@uk.ibm.com >
Reviewed-By: Colin Ihrig <cjihrig@gmail.com >
Reviewed-By: Yongsheng Zhang <zyszys98@gmail.com >
2019-07-15 00:04:50 +02:00
Ruben Bridgewater
e939b8f13b
repl: handle stage-3 language features properly
...
This adds stage-3 language features to acorn so that the REPL is
able to parse these features properly. Otherwise these would cause
SyntaxErrors.
PR-URL: https://github.com/nodejs/node/pull/27400
Fixes: https://github.com/nodejs/node/issues/27391
Fixes: https://github.com/nodejs/node/issues/25835
Reviewed-By: Anna Henningsen <anna@addaleax.net >
Reviewed-By: Michaël Zasso <targos@protonmail.com >
2019-04-30 16:22:57 +02:00
Ruben Bridgewater
82f8821401
repl: add replDefaults to customize the writer
...
So far it was not possible to modify the inspection defaults used by
the REPL from the running instance itself. This introduces a new
property on `util.inspect` which is only used inside the REPL and which
allows to modify the used inspection defaults at any point of time.
PR-URL: https://github.com/nodejs/node/pull/26375
Reviewed-By: James M Snell <jasnell@gmail.com >
2019-03-08 04:44:56 +01:00