Spyder: Add an option to prevent using Enter to select completions

Created on 13 May 2020  路  7Comments  路  Source: spyder-ide/spyder

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

Code Completion Discussion

Most helpful comment

We'll take a look at this for 4.2.0.

All 7 comments

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 ?

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').

  • [X] 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' :-)

@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

We'll take a look at this for 4.2.0.

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.

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

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.

Was this page helpful?
0 / 5 - 0 ratings