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 disruptive autocomplete without inspector #40661

Merged
merged 4 commits into from
May 12, 2024

Conversation

Linkgoron
Copy link
Member

@Linkgoron Linkgoron commented Oct 29, 2021

Fix an issue where the autocomplete wrongly autocompletes a value from a correct value to an undefined value when hitting return - when node is built with the --without-inspector flag by disabling the preview view.

I could think of three ways on how to solve this, however I'd be happy to implement something different, if there are better options. The three solutions that I thought of were:

  1. Completely disable the completer when the inspector is disabled.
  2. Show the autocompletion preview, but don't "commit" it when hitting return (I thought that it's a bit confusing when I tried it out).
  3. Disable the preview but keep the completer (e.g. for tab completion, for keywords or built-in modules).

I chose the third option, as it's still possible to use tab completion for built-in modules, keywords and maybe other completions that don't need the inspector. Note that this does make it possible to be on a "correct" value and press tab and move to a different value, even though the original value exists, but I thought that it's an OK compromise vs removing auto-complete completely.

fixes: #40635

@nodejs-github-bot nodejs-github-bot added needs-ci PRs that need a full CI run. repl Issues and PRs related to the REPL subsystem. labels Oct 29, 2021
Copy link
Member

@Trott Trott left a comment

Choose a reason for hiding this comment

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

Would it be reasonable/not-onerous to add a test for this?

@Linkgoron
Copy link
Member Author

Would it be reasonable/not-onerous to add a test for this?

Done. Basically just copied the test-repl-preview.js and modified it to my new fix. For reference, the test fails without the fix with the following error:

  [
+   'r\x1B[90me\x1B[39m\x1B[9G\x1B[0Ke\r',
+   'Uncaught ReferenceError: re is not defined'
-   'r\r',
-   '\x1B[33m5\x1B[39m'
  ]

@Trott
Copy link
Member

Trott commented Oct 31, 2021

@nodejs/repl

@nodejs-github-bot
Copy link
Collaborator

@Trott
Copy link
Member

Trott commented Nov 2, 2021

You'll want to rebase against master to fix a few CI issues. Sorry about the inconvenience.

@nodejs-github-bot
Copy link
Collaborator

Copy link
Member

@BridgeAR BridgeAR left a comment

Choose a reason for hiding this comment

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

LGTM with my comment addressed.

@@ -366,7 +366,8 @@ function setupPreview(repl, contextSymbol, bufferSymbol, active) {

const showPreview = () => {
// Prevent duplicated previews after a refresh.
if (inputPreview !== null || !repl.isCompletionEnabled) {
if (inputPreview !== null || !repl.isCompletionEnabled ||
!process.features.inspector) {
Copy link
Member

@BridgeAR BridgeAR Nov 4, 2021

Choose a reason for hiding this comment

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

Please move the condition up to the start of the setup function. There are already two conditions that deactivate the preview as well and it would be good to combine this instead of executing lots of code that is not required anyway.

See https://github.com/nodejs/node/pull/40661/files#diff-d2785f46e53f8d956b9a838d9b22ea519b7eb6f51cc84d33885c231043cf4530R144-R145

Copy link
Member

Choose a reason for hiding this comment

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

Ping @Linkgoron

Copy link
Member Author

Choose a reason for hiding this comment

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

Do you want me to move the prexisting condition as well (!repl.isCompletionEnabled), or just the specific condition that I've added?

Copy link
Member

Choose a reason for hiding this comment

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

Thanks! The isCompletionEnabled is something that changes during usage. It is set while the repl is paused. As such, it should stay where it is.

Copy link
Member Author

@Linkgoron Linkgoron Jan 29, 2022

Choose a reason for hiding this comment

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

@BridgeAR This change had a behavioural change, it broke the move cursor completion without the inspector (e.g. test-repl-history-navigation.js line 559). The issue is caused by _moveCursor not being redefined in line 491 in utils.js (as it still works for built-in modules like util).

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

Linkgoron and others added 4 commits May 11, 2024 16:41
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: nodejs#40635
@aduh95 aduh95 added the author ready PRs that have at least one approval, no pending requests for changes, and a CI started. label May 11, 2024
@nodejs-github-bot
Copy link
Collaborator

@nodejs-github-bot
Copy link
Collaborator

@aduh95 aduh95 merged commit 1223294 into nodejs:main May 12, 2024
41 of 53 checks passed
@aduh95
Copy link
Contributor

aduh95 commented May 12, 2024

Landed in 1223294

targos pushed a commit that referenced this pull request May 12, 2024
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: #40635
PR-URL: #40661
Fixes: #40635
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
marco-ippolito pushed a commit that referenced this pull request Jun 17, 2024
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: #40635
PR-URL: #40661
Fixes: #40635
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
marco-ippolito pushed a commit that referenced this pull request Jun 17, 2024
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: #40635
PR-URL: #40661
Fixes: #40635
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
marco-ippolito pushed a commit that referenced this pull request Jun 17, 2024
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: #40635
PR-URL: #40661
Fixes: #40635
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
eliphazbouye pushed a commit to eliphazbouye/node that referenced this pull request Jun 20, 2024
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: nodejs#40635
PR-URL: nodejs#40661
Fixes: nodejs#40635
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
bmeck pushed a commit to bmeck/node that referenced this pull request Jun 22, 2024
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: nodejs#40635
PR-URL: nodejs#40661
Fixes: nodejs#40635
Reviewed-By: Rich Trott <rtrott@gmail.com>
Reviewed-By: Ruben Bridgewater <ruben@bridgewater.de>
Reviewed-By: James M Snell <jasnell@gmail.com>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
author ready PRs that have at least one approval, no pending requests for changes, and a CI started. needs-ci PRs that need a full CI run. repl Issues and PRs related to the REPL subsystem.
Projects
None yet
Development

Successfully merging this pull request may close these issues.

repl: internal repl's autocomplete is disruptive without inspector
7 participants