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

Console: Conflict between Accept Suggestion/Execute #550

Open
Tracked by #1603
jmcphers opened this issue May 8, 2023 · 13 comments
Open
Tracked by #1603

Console: Conflict between Accept Suggestion/Execute #550

jmcphers opened this issue May 8, 2023 · 13 comments
Labels
area: console Issues related to Console category.

Comments

@jmcphers
Copy link
Collaborator

jmcphers commented May 8, 2023

To reproduce, close all code editors and start a new Python interpreter session. Try to run the following code by typing it into the Console and pressing Enter:

import pandas as pd

This is one of the most commonly typed lines of code in a data science project, but it's surprisingly difficult to run in Positron. When you type "pd", the spelling-based autocomplete helpfully suggest "pandas".

image

Pressing Enter accepts the suggestion, so instead of actually running this code, you now have import pandas as pandas. Even if you go back and edit "pandas" to read "pd" again, you'll usually wind up with "pandas" again as the autocomplete kicks in.

I'm not sure what the right solution is to this problem...

  • Should we disable the dictionary-based autocompletion engine in the Console? It is responsible for this noise.
  • Should we remove the binding for Enter as a way to accept completions in the Console? Tab still works fine, for example.
  • Should we make the autocomplete less aggressive, so that e.g. it shows up after a longer delay and/or more characters typed, so it is less likely to get in the way like this?
  • Should we run away from home and live in the woods?
@jmcphers jmcphers added this to the Internal Preview milestone May 8, 2023
@seeM
Copy link
Contributor

seeM commented Jul 19, 2023

I remember being frustrated by this issue before, but I don't seem to be getting it anymore. I'm not sure what changed.

Do you still see the issue on your end @jmcphers?

@juliasilge
Copy link
Contributor

I believe I still see this issue. In both of these, I have hit Enter:

r-accept-suggestion

python-accept-suggestion

@juliasilge
Copy link
Contributor

juliasilge commented Jul 19, 2023

I think I would vote for this option (if running away is off the table):

Should we remove the binding for Enter as a way to accept completions in the Console? Tab still works fine, for example.

I like Tab for accepting completions.

I really like having autocomplete in the console. The autocomplete doesn't feel overly aggressive to me (I don't think we should make it so slow that it solves this problem) but IMO it could maybe be dialed back a smidge in terms of both time and number of characters.

@kevinushey
Copy link
Contributor

We allow Enter to accept completion results in the RStudio Console -- do we find that behavior annoying, or are the differences in how completions are presented to the user in each case enough to make Enter still feel okay in RStudio?

@juliasilge
Copy link
Contributor

Oh yeah, wow, I had not really yet absorbed how dramatically different the autocomplete is in RStudio:

potato-rstudio

I can't imagine using Enter is a problem for RStudio users, given how completions are presented. To sum up my thoughts:

  • I would miss autocomplete in the console a lot.
  • I have realized I only use Tab for autocomplete (no idea how common Tab vs. Enter is).
  • The Positron autocomplete didn't feel overly aggressive to me until I went back and looked carefully at RStudio. I feel like waiting for 3 characters (looks like RStudio's behavior?) will be an improvement (it would solve import pandas as pd) but it doesn't really address other conflicts between "accept" and "execute".

@kevinushey
Copy link
Contributor

The other thing we do in RStudio is allow a (user-configurable) delay before completions are presented to the user. This helps avoid the completion popup flashing around while you type.

In VSCode, I found it annoying at first that the completion popup immediately displays after typing (it's kind of distracting), but I got used to it eventually.

@jmcphers
Copy link
Collaborator Author

Yeah, I think the difference is that Positron's autocomplete is just way more aggressive. It shows up faster (both in terms of delay and number of characters), shows a whole lot more stuff (dictionary completions, much more exhaustive fuzzy matching, etc.), has bigger popups, etc.

I don't think we need to nerf that behavior to match RStudio's, but I also think the current behavior is just too aggressive to work well in the console where Enter needs to run code. Maybe just nudging the delay before completions appear would be enough.

@jmcphers
Copy link
Collaborator Author

Some more discussion of this in #1440, which I think argues that we really do need to tone this down a little, at least in the Console.

@DavisVaughan
Copy link
Contributor

#1497 made it so that we wait until 3 characters have been typed before showing completions, like RStudio.

There has also been some discussion about the fact that the Positron default delay of 10ms before showing completions is super aggressive compared to the RStudio delay of 250ms. It doesn't give you the chance to "beat" the autocompletion engine. i.e. try typing ?match followed by Enter really fast in RStudio vs Positron. In RStudio you can likely beat any autocompletion pop ups and that first Enter will take you straight to the help page. In Positron that first Enter will likely be to accept the autocompletion popup, and then you need a second Enter to submit the actual code.

@garrettgman
Copy link

garrettgman commented Oct 11, 2023

The really fast autocomplete frustrates me when I try to open help pages. I have to hit Enter twice; but, worse to me, autocomplete adds an unnecessary () as it exits, which makes me feel like the IDE kept me from the help page so it could chide me for my syntax (FWIW, you don't need () to open a help page).

For me, I like being able to beat the 250ms autocomplete when I try, and I don't mind waiting 250ms or pressing tab when I want an autocomplete.

Here I try to run ?geom_line.

help.mov

@softwarenerd
Copy link
Contributor

Things seem to have improved. I cannot reproduce the original issue:

Screen.Recording.2023-11-29.at.9.28.06.PM.mov

#1440 has been closed.
#1497 has been closed.

Typing ?match seems to behave well.

My sense is that we can close this issue.

@juliasilge
Copy link
Contributor

juliasilge commented Dec 7, 2023

I can now do import pandas as pd but I still think we have a pretty significant issue, at least for R. Look at me try to execute potato in Positron 2023.12.0 (Universal) build 22:

potato.mov

Compare it to the behavior in RStudio, where you will not get all these suggestions accepting on Enter when you are trying to execute. This example is somewhat contrived but I run into it trying to do "real" work too. I'll keep my eyes out for a better example.

@juliasilge
Copy link
Contributor

I do still see the problem with match():

match.mov

When I hit Enter after typing ?match it should execute, not complete to match().

@wesm wesm added the area: console Issues related to Console category. label Feb 29, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
area: console Issues related to Console category.
Projects
None yet
Development

No branches or pull requests

8 participants