Skip to content

Conversation

@Linkgoron
Copy link
Contributor

@LinkgoronLinkgoron 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-botnodejs-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

@TrottTrott 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
ContributorAuthor

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

@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

@BridgeARBridgeAR 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.

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

@BridgeARBridgeARNov 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.

Copy link
ContributorAuthor

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
ContributorAuthor

@LinkgoronLinkgoronJan 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

Linkgoronand 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
@aduh95aduh95force-pushed the repl-no-ispector-fix branch from e69ebdf to 95b5272CompareMay 11, 2024 13:41
@aduh95aduh95 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

@aduh95aduh95 merged commit 1223294 into nodejs:mainMay 12, 2024
@aduh95
Copy link
Contributor

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: #40661Fixes: #40635 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
@targostargos mentioned this pull request May 13, 2024
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: #40661Fixes: #40635 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
@marco-ippolitomarco-ippolito mentioned this pull request Jun 17, 2024
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: #40661Fixes: #40635 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
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: #40661Fixes: #40635 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
ebouye pushed a commit to ebouye/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#40661Fixes: nodejs#40635 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
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#40661Fixes: nodejs#40635 Reviewed-By: Rich Trott <[email protected]> Reviewed-By: Ruben Bridgewater <[email protected]> Reviewed-By: James M Snell <[email protected]>
Sign up for freeto join this conversation on GitHub. Already have an account? Sign in to comment

Labels

author readyPRs that have at least one approval, no pending requests for changes, and a CI started.needs-ciPRs that need a full CI run.replIssues 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

@Linkgoron@Trott@nodejs-github-bot@aduh95@jasnell@antsmartian@BridgeAR