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

Add an option to prevent using Enter to select completions #12728

Open
OverLordGoldDragon opened this issue May 13, 2020 · 19 comments
Open

Add an option to prevent using Enter to select completions #12728

OverLordGoldDragon opened this issue May 13, 2020 · 19 comments

Comments

@OverLordGoldDragon
Copy link
Contributor

OverLordGoldDragon commented May 13, 2020

When a typed method name is matched exactly with suggestion's, I have a "press Enter twice or click away or press space" overhead for any linter suggestion. I understand the linter suggestion also includes a docstring excerpt, or that a 'complete' method name can be another method name's substring, but my request can be handled as follows:

  • If typed method matches any linter suggestion exactly, then automatically [Enter] the suggestion upon typing, without consuming the next keystroke - unless the input extends a method's name (i.e. is alphanumeric or underscore)
  • So, if I type .stem and Enter, I should newline (the Enter isn't consumed by the linter)
  • Can make this a configurable so current behavior remains an option

image

@dalthviz
Copy link
Member

Hi @OverLordGoldDragon thanks for the feedback! I think probably having an option for such behavior could be worthy for some people but I'm not sure how complex could it be to implement, what do you guys think @spyder-ide/core-developers ?

@bcolsen
Copy link
Member

bcolsen commented May 13, 2020

The easiest thing to do here is to give an option to have enter not complete it ever. I would activate that as I always use tab to complete.

My only complaint about @OverLordGoldDragon is the difficulty in explaining the option in the preferences, while disabling enter is pretty easy(and covers the use case if you are into 'tab').

  • Enter accepts code completions. (# Checked by default)

This could go along with disabling "tab" #12682.

As an aside tab will start a completion and accept it but you can't accept the completion with ctrl+space or whatever you set the completion hotkey too. This would be quite important if you disabled 'tab' and 'enter' :-)

@OverLordGoldDragon
Copy link
Contributor Author

OverLordGoldDragon commented May 13, 2020

@bcolsen How about: "If enabled, pressing Enter will newline instead of inserting code completion" (what else could Enter do?). And yes, I'd be fine with using Tab instead of Enter.

If that doesn't suffice, you do have at least 202 characters to work with:

image

@ccordoba12
Copy link
Member

We'll take a look at this for 4.2.0.

@ccordoba12 ccordoba12 changed the title Auto-confirm linter suggestion if matching exactly [Request] Prevent using Enter to select completions May 14, 2020
@ccordoba12 ccordoba12 changed the title Prevent using Enter to select completions Add an option to prevent using Enter to select completions May 14, 2020
@ishipachev
Copy link

I would support this with such Pythonic case:
autocompletion
After "0." I would like to go to the next line. But hitting Enter force me to put first suggestion from autocomplete.
And some other cases when I want to move to newline, instead of using something from autocomplete form.
My recipe would be let user to switch off "Enter" as a hotkey for autocompleting. Tab works nice for such situations and as far as I know is mostly used in others IDEs.

@ccordoba12
Copy link
Member

Thanks for the explanation @ishipachev! We'll add an option to configure this in 4.2 for sure.

@OverLordGoldDragon
Copy link
Contributor Author

OverLordGoldDragon commented Jun 1, 2020

Another use-case, just to be sure it's covered; prepending self. triggers suggestions as if there's nothing after the .:

(gather_fns was typed first.) Enter should be able to bypass these.

@ccordoba12 ccordoba12 added this to the v4.2.0 milestone Aug 9, 2020
@ccordoba12 ccordoba12 modified the milestones: v4.2.0, v4.2.1 Sep 19, 2020
@ccordoba12 ccordoba12 modified the milestones: v4.2.1, v4.2.2 Nov 12, 2020
@ccordoba12 ccordoba12 removed this from the v4.2.2 milestone Jan 6, 2021
@NightSightGit
Copy link

NightSightGit commented Apr 22, 2021

@ccordoba12 I tried both the 4.2.5 and 5.0.1 release but can't find the option to disable enter to complete anywhere. I do like to use the auto complete feature with tab but it's driving me crazy that it is also auto completing when I want to return to the next line. I have been searching all over the Internet on how to disable it but can't find anything besides this issue thread, which mentions it should be added since 4.2?

@ccordoba12
Copy link
Member

Sorry but we haven't had time to add an option for this.

@RemiDav
Copy link

RemiDav commented Apr 24, 2022

Any update on this? It has been one year since the last message.

This is by far the most annoying issue on Spyder.
Using Enter for newline or Ctrl+Enter for "run block" often inserts unwelcomed code instead of executing the desired action.

@ccordoba12
Copy link
Member

Hey @RemiDav, sorry we haven't looked at this. But I'll schedule it so we can address it in one of our next versions.

@ccordoba12 ccordoba12 added this to the v5.3.2 milestone Apr 24, 2022
@ccordoba12 ccordoba12 modified the milestones: v5.3.2, v5.3.3 May 4, 2022
@ccordoba12 ccordoba12 modified the milestones: v5.3.3, v5.3.4 Jun 20, 2022
@dcknuth
Copy link

dcknuth commented Jan 15, 2023

Want to support doing something here. Maybe shift + Enter does not complete and always gives a newline? I like only tab autofills best though.

@geograz
Copy link

geograz commented Mar 8, 2023

Is there any development of this issue? Would be nice to turn this off.

@ccordoba12
Copy link
Member

@geograz, no, there hasn't been. We'll try to address it in Spyder 6, to be released in the second half of the year.

@DeltaMod
Copy link

DeltaMod commented Mar 22, 2024

@geograz, no, there hasn't been. We'll try to address it in Spyder 6, to be released in the second half of the year.

This is still a major nuisance.
Not only is the autocomplete extremely aggressive for things it shouldn't even try to autocomplete for, it wouldn't even be a problem if the "Code Completion" keyboard shortcut in the settings could actually be assigned as the sole shortcut.

Let's say I have a parameter that just says dataset = 1 and I have parameters that include numbers (like p0/x0/Plot0 you name it)
If I want to quickly swap to dataset = 0, and run the codeblock using Ctrl+Enter, this autocomplete will sneak in and replace my 0 with the first item in the autocomplete list composed of all variables that contain the letter 0? I cannot count the number of times I have accidentally had "ArithmeticError" autocompleted for when I've tried to run a code block.

@ccordoba12 ccordoba12 modified the milestones: v6.2.0, v6.1.0 Mar 27, 2024
@ccordoba12
Copy link
Member

ccordoba12 commented Mar 27, 2024

@DeltaMod, I understand your frustration and we'll try to implement this feature for Spyder 6.1.0, to be released during the second half of the year (6.0 will be released in a couple of months but we don't have time for that).

In the meantime, you could disable completions on the fly to avoid that annoying behavior. You can do that by going to the menu Tools > Preferences, then selecting the pane Completion and linting > General and finally unchecking the option called Show completions on the fly. Let us know if that works for you.

@RemiDav
Copy link

RemiDav commented Mar 27, 2024

We'll take a look at this for 4.2.0.

Thanks for the explanation @ishipachev! We'll add an option to configure this in 4.2 for sure.

Then it was 5.3.2, 5.3.3, 5.3.4 ... now 6.1.0

Realistically, will this ever be fixed? Or there will always be something with higher priority and it will keep being pushed back to 13.1.0 and further?

@ccordoba12
Copy link
Member

Sorry for the multiple delays but this is a bit low priority for us because it doesn't affect the way we use Spyder. I develop Spyder with Spyder and haven't encountered this problem so far, but I understand it's annoying for users that evaluate code frequently (which is not my case).

In addition, we didn't want to add new features to the Editor before doing a big refactoring that was planned for a long time (its purpose was to improve interoperability between plugins with a new API we created for Spyder 5). The good news is that that refactoring is finally done (see PR #21353, merged last week). But since we're wrapping things up for Spyder 6.0, we won't have time to address this for that release (as I said above).

However, I'll make sure this lands in 6.1.0 because the conditions are finally there to make it a reality.

@ccordoba12 ccordoba12 self-assigned this Mar 27, 2024
@RemiDav
Copy link

RemiDav commented Mar 27, 2024

Thanks a lot for the details. I'll remain optimistic about it then.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

10 participants