diff options
author | Roy Li <ruyili2002@gmail.com> | 2023-03-16 15:46:50 -0400 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-03-16 19:46:50 +0000 |
commit | 2c7174a5a245ff5d7e4e9f7a1fafb578be9a3ef2 (patch) | |
tree | df6b1f88bf74eb28525ca261da71635d741e996e | |
parent | 56731f2f8d45b8bd16de77276c3f7ce55d2f7b22 (diff) |
fix(repl): Hide indexable properties in tab completion (#18141)
Closes #17831. This change hides the indices of any indexed collection
when triggering tab completion for object properties in the REPL.
An example is shown in the issue, but for verbosity here is another.
Before the change:
```
> const arr = new Uint8ClampedArray([1, 2, 3])
undefined
> arr.
0 map
1 reverse
2 reduce
...
```
After the change:
```
> const arr = new Uint8ClampedArray([1, 2, 3])
undefined
> arr.
constructor reduce
BYTES_PER_ELEMENT reduceRight
buffer set
...
```
Co-authored-by: David Sherret <dsherret@users.noreply.github.com>
-rw-r--r-- | cli/tests/integration/repl_tests.rs | 16 | ||||
-rw-r--r-- | cli/tools/repl/editor.rs | 2 |
2 files changed, 17 insertions, 1 deletions
diff --git a/cli/tests/integration/repl_tests.rs b/cli/tests/integration/repl_tests.rs index 52510a637..f7bd627c3 100644 --- a/cli/tests/integration/repl_tests.rs +++ b/cli/tests/integration/repl_tests.rs @@ -1057,3 +1057,19 @@ fn npm_packages() { assert!(err.is_empty()); } } + +#[test] +fn pty_tab_indexable_props() { + util::with_pty(&["repl"], |mut console| { + console.write_line("const arr = [1, 2, 3]"); + console.write_line("arr.\t\t"); + console.write_line("close();"); + + let output = console.read_all_output(); + println!("output"); + assert_contains!(output, "constructor"); + assert_contains!(output, "sort"); + assert_contains!(output, "at"); + assert_not_contains!(output, "0", "1", "2"); + }); +} diff --git a/cli/tools/repl/editor.rs b/cli/tools/repl/editor.rs index e1cda21e1..e12b9314b 100644 --- a/cli/tools/repl/editor.rs +++ b/cli/tools/repl/editor.rs @@ -109,7 +109,7 @@ impl EditorHelper { own_properties: None, accessor_properties_only: None, generate_preview: None, - non_indexed_properties_only: None, + non_indexed_properties_only: Some(true), }), ) .ok()?; |