Skip to content

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

Closed
starkwang wants to merge 1 commit into
nodejs:masterfrom
starkwang:fix-tab-complete
Closed

repl: fix tab completion for object properties with special characters#21556
starkwang wants to merge 1 commit into
nodejs:masterfrom
starkwang:fix-tab-complete

Conversation

@starkwang

@starkwangstarkwang commented Jun 27, 2018

Copy link
Copy Markdown
Contributor

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

Copy link
Copy Markdown
Collaborator

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

Copy link
Copy Markdown
Member

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

@TimothyGuTimothyGu left a comment

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

You might find https://github.com/devsnek/node-repl-prototype/blob/5e72bed5a127c0b3e1c7289d75c3eb157db43522/src/repl.js#L154-L169 to be helpful to enhance the behavior for [ property references.

Comment threadlib/repl.js Outdated

Copy link
Copy Markdown
Member

Choose a reason for hiding this comment

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

With acorn in tree, we could actually do something like

https://github.com/devsnek/node-repl-prototype/blob/5e72bed5a127c0b3e1c7289d75c3eb157db43522/src/util.js#L3-L24

for higher accuracy.

@starkwang

Copy link
Copy Markdown
ContributorAuthor

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
Copy Markdown
ContributorAuthor

@starkwang

Copy link
Copy Markdown
ContributorAuthor

Landed in 4f15122

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: #21556Fixes: #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: #21556Fixes: #21201
Reviewed-By: Tiancheng "Timothy" Gu <timothygu99@gmail.com>
Reviewed-By: John-David Dalton <john.david.dalton@gmail.com>
@targostargos mentioned this pull request Jul 3, 2018
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

replIssues 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

@starkwang@nodejs-github-bot@addaleax@jdalton@TimothyGu