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 editor setting to toggle automatic code completion #68140

Merged
merged 1 commit into from
Jul 12, 2023

Conversation

quinnyo
Copy link
Contributor

@quinnyo quinnyo commented Nov 1, 2022

This adds a boolean editor setting (text_editor/completion/auto_code_complete) and implementation in the code editor to allow automatic code completion to be disabled. It's a pretty small, straightforward change, I think -- but I don't know what I did wrong yet!

Fixes #68139.

@quinnyo quinnyo requested review from a team as code owners November 1, 2022 20:52
@Calinou Calinou added this to the 4.0 milestone Nov 1, 2022
@MewPurPur
Copy link
Contributor

I'm on board with the idea. Code LGTM, can't think of anything that could possibly go wrong (famous last words)

@Mickeon
Copy link
Contributor

Mickeon commented Nov 2, 2022

I mean, sure! The editor setting makes sense on its own, but... quoting the issue:

I find the built-in code completion to be quite aggressive/invasive. It often makes editing scripts stressful, unpleasant and time-consuming.

the fact that the autocompletion in 4.0 is SO ATROCIOUSLY invasive users may want to outright disable it unless manually brought up is quite damning evidence that perhaps something more should be... done about it.

@Paulb23
Copy link
Member

Paulb23 commented Nov 6, 2022

Rather then adding a new setting, would it be worth making a delay of 0 disable it?

@Riteo
Copy link
Contributor

Riteo commented Nov 14, 2022

@Paulb23 that doesn't sound very intuitive to me. Is it possible to set it to a negative value? That'd map much better, but it may still be less user-friendly than a plain toggle.

@quinnyo
Copy link
Contributor Author

quinnyo commented Dec 24, 2022

synced with master

@YuriSizov YuriSizov modified the milestones: 4.0, 4.1 Feb 10, 2023
@quinnyo
Copy link
Contributor Author

quinnyo commented May 18, 2023

Some notes based on comments here and in the issue:

Improving the suggestions themselves is a worthy endeavour, but it is a separate one. The fact that the suggestions pop up automatically is the issue. It doesn't matter how good the suggestions are.

I don't think overloading the delay setting (i.e. allowing an out of range or practically infinite value) is a good way to go. It's messy and less obvious than a dedicated setting.
Having a dedicated setting communicates very clearly that you can turn the feature on/off. It also allows keeping your preferred value, if/when the feature is re-enabled.

@YuriSizov YuriSizov modified the milestones: 4.1, 4.2 Jun 14, 2023
@akien-mga
Copy link
Member

I support adding this.

I'm not sure about the name of the setting though. auto_code_complete sounds like the code would be completed automatically, while what this does is that it shows a code completion tooltip with suggestions - it doesn't actually change the code. That's different to auto_brace_complete which you modeled it after, which after inserts braces automatically.

I'd suggest maybe code_complete_enabled, which I'm not fully happy with either but it matches code_complete_delay so it's clear that the two are related.

While at it, could you add ,or_greater to the hint for code_complete_delay so that users who want it can extend the timer beyond 5 s if they wish so, as was done in #78284. I commented that it's not the right way to offer an opt out for the timer itself, but some people might want it longer than 5 s anyway.

@quinnyo
Copy link
Contributor Author

quinnyo commented Jun 20, 2023

I've made the suggested changes.

editor/code_editor.h Outdated Show resolved Hide resolved
Copy link
Member

@akien-mga akien-mga left a comment

Choose a reason for hiding this comment

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

Two minor changes needed, but looks great otherwise.

@quinnyo
Copy link
Contributor Author

quinnyo commented Jun 20, 2023

Done and done!

(Not sure if I'll ever get used to in-class initialisers...)

@YuriSizov
Copy link
Contributor

Sorry for the CI failure, it's not an issue with your code. But you need to do a rebase against master and force-push again.

@quinnyo
Copy link
Contributor Author

quinnyo commented Jun 20, 2023

Done!

@@ -837,6 +837,9 @@
<member name="text_editor/completion/code_complete_delay" type="float" setter="" getter="">
The delay in seconds after which autocompletion suggestions should be displayed when the user stops typing.
</member>
<member name="text_editor/completion/code_complete_enabled" type="bool" setter="" getter="">
If [code]true[/code], code completion will be triggered automatically after [member text_editor/completion/code_complete_delay]. If [code]false[/code], you can still trigger completion manually by pressing [kbd]Ctrl + Space[/kbd] ([kbd]Cmd + Space[/kbd] on macOS).
Copy link
Contributor

Choose a reason for hiding this comment

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

Sorry for a late review, but since this is configurable we should mention that this is only true by default.

Suggested change
If [code]true[/code], code completion will be triggered automatically after [member text_editor/completion/code_complete_delay]. If [code]false[/code], you can still trigger completion manually by pressing [kbd]Ctrl + Space[/kbd] ([kbd]Cmd + Space[/kbd] on macOS).
If [code]true[/code], code completion will be triggered automatically after [member text_editor/completion/code_complete_delay]. If [code]false[/code], you can still trigger completion with a shortcut (by default, [kbd]Ctrl + Space[/kbd] on Linux and Windows, [kbd]Cmd + Space[/kbd] on macOS).

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

Successfully merging this pull request may close these issues.

There is no way to disable automatic code completion in the text editor
8 participants