Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

repl: fix tab completion for object properties with special characters #21556

Closed
wants to merge 1 commit into from

Conversation

starkwang
Copy link
Contributor

@starkwang starkwang commented Jun 27, 2018

The old RegExp will pass property names like "hello world!" when filtering the results of tab complete. This change is to fix it.

By the way, now the repl module doesn't support tab complete like obj[<tab>. Is there any plan for this?

Fixes: #21201

Checklist
  • make -j4 test (UNIX), or vcbuild test (Windows) passes
  • tests and/or benchmarks are included
  • commit message follows commit guidelines

@nodejs-github-bot nodejs-github-bot added the repl Issues and PRs related to the REPL subsystem. label Jun 27, 2018
@addaleax
Copy link
Member

Would it be possible to generate proper tab completions for the other keys? I.e. autocomplete obj.hello to obj['hello, world']?

Copy link
Member

@TimothyGu TimothyGu left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

lib/repl.js Outdated
// Filters the elements that pass the regexp:
// 1. Starting with A-Z, a-z, $ or _
// 2. Following with A-Z, a-z, 0-9, $ or _
return /^[A-Za-z_$][A-Za-z0-9_$]*$/.test(item);
Copy link
Member

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@starkwang
Copy link
Contributor Author

Would it be possible to generate proper tab completions for the other keys? I.e. autocomplete obj.hello to obj['hello, world']?

@addaleax Rewrite the user input from obj.hello to obj['hello, world'] might exceed the scope of autocomplete. It should not rewrite but append something after the user input.

The old RegExp will pass property names like `"hello world!"`
when filtering the results of tab complete. This change is to
fix it.

Fixes: nodejs#21201
@starkwang
Copy link
Contributor Author

@starkwang
Copy link
Contributor Author

Landed in 4f15122

@starkwang starkwang closed this Jul 2, 2018
starkwang added a commit that referenced this pull request Jul 2, 2018
The old RegExp will pass property names like `"hello world!"`
when filtering the results of tab complete. This change is to
fix it.

Fixes: #21201

PR-URL: #21556
Fixes: #21201
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
targos pushed a commit that referenced this pull request Jul 3, 2018
The old RegExp will pass property names like `"hello world!"`
when filtering the results of tab complete. This change is to
fix it.

Fixes: #21201

PR-URL: #21556
Fixes: #21201
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
@targos targos mentioned this pull request Jul 3, 2018
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

Bad tab completion for object properties with special characters
5 participants