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

Always display enum values first when autocompleting an enum #7913

Closed
tokengamedev opened this issue Sep 29, 2023 · 3 comments · Fixed by godotengine/godot#86667
Closed

Always display enum values first when autocompleting an enum #7913

tokengamedev opened this issue Sep 29, 2023 · 3 comments · Fixed by godotengine/godot#86667

Comments

@tokengamedev
Copy link

Describe the project you are working on

Multiple Projects

Describe the problem or limitation you are having in your project

Currently during the autocomplete of an Enum type.
It is listed as given below:

enum STATUS { IDLE, RUNNING, ACTIVE}

image

The values of the enum are sorted in alphabetical order with all other functions and parameters. It will be more convenient if the values are at the top.

Describe the feature / enhancement and how it helps to overcome the problem or limitation

In the auto-complete menu all the values of the enum to be at the top as shown below:

enum_autocomplete

There are two things to it.

  1. all the Enum values are at the top.
  2. It is ordered by the way it has been defined or in other words their values(integer)

Describe how your proposal will work, with code, pseudo-code, mock-ups, and/or diagrams

listed above

If this enhancement will not be used often, can it be worked around with a few lines of script?

It will be used always

Is there a reason why this should be core and not an add-on in the asset library?

Autocomplete is part of core

@Calinou Calinou changed the title Enhancement to auto-complete of enums Always display enum values first when autocompleting an enum Oct 1, 2023
@TheColorRed
Copy link

I feel this shouldn't only be true for enums but all types. It seems as if it shows irrelevant things first, even when alphabetical is disabled in the settings.

I feel it should order Auto completions with itself first followed by the parent then grandparent and so on...

@HolonProduction
Copy link
Member

HolonProduction commented Dec 30, 2023

I feel it should order Auto completions with itself first followed by the parent then grandparent and so on...

That's how it is supposed to work.

Given the following class structure:

class A:
    ...

class B extends A:
    ...

class C extends B:
    ...

The autocompletion for something of type C should have the following structure:

  1. properties and methods of C in alphabetical order
  2. properties and methods of B in alphabetical order
  3. properties and methods of A in alphabetical order

If it doesn't work that way it is a bug and you should report it.

Edit: I kindof misread the proposal into requesting that Enum values be sorted in declaration order instead of alphabetical. That enum values don't appear at top at all seems more like a bug then intended behavior.

Regarding the proposal I like the idea, but implementing it could be hard. The sorting is done by the code edit, and is not tied to GDScript (it could also receive suggestions from another language) and so getting access to the declaration order is hard. We could abuse the location property to achieve it but that feels like a hack, and wouldn't work for unnamed enums (since it would interfere with the real use for location in that case).

@tokengamedev
Copy link
Author

Regarding the proposal I like the idea but implementing it could be hard. The sorting is done by the code edit, and is not tied to GDScript

I kind of understand, but to make matter more complicated, another thought was to display the class name to which the item belongs. It would be a different proposal altogether, but it makes sense, where the function/property is coming from.
Now adding the two, will it not possible to pass the sort order along with item name and class name, which code edit can use to sort, and display based on context

wouldn't work for unnamed enums (since it would interfere with the real use for location in that case).

I think unnamed Enums work as group of constants, so it should display as constants only, sorted alphabetically. It is not worth the effort to custom sort them though.

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

Successfully merging a pull request may close this issue.

5 participants