-
-
Notifications
You must be signed in to change notification settings - Fork 21.6k
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
Improve sorting of Code Completion options. #59633
Improve sorting of Code Completion options. #59633
Conversation
8b1b386
to
41c2699
Compare
ERR_CONTINUE(!op.has("location")); | ||
option.location = op["location"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I was not sure if here you would prefer location to be optional:
if (op.has("location)){
option.location = op["location'];
}
So I just followed what was already there. Using ERR_CONTINUE makes it mandatory to provide.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its ok to enforce it
Yes, it should. That item will still be suggested but it will be much further down the list. |
@novaplusplus Actually I just tested, doesnt look like it will help with that specific scenario (assigning a built-in type to a variable). Interestingly "float" does not come up as an option at all. That appears to be an issue which is outside of the scope of this PR though. |
ERR_CONTINUE(!op.has("location")); | ||
option.location = op["location"]; |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I think its ok to enforce it
core/object/script_language.h
Outdated
@@ -312,20 +312,29 @@ class ScriptLanguage : public Object { | |||
}; | |||
|
|||
struct CodeCompletionOption { | |||
enum Location { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
I would probably be put as an enum of ScriptLanguage and bind it in ScriptLanguageExtension like the other enums, so the extensions can have access to it. Otherwise you dont know what they are from it.
41c2699
to
f969a73
Compare
That's a shame... maybe there's another issue or PR already made about this. It's quite frustrating - if I were to hit "enter" at the time of that screenshot, it would have automatically replaced "float" with "AudioEffectLowPassFilter", which is just beyond absurd... |
Remember that you can change the completion accept shortcuts in |
f969a73
to
4ab605d
Compare
Done by ordering options by their location in the code - e.g. local, parent class, global, etc.
Thanks! |
there is a pr for the built-in types... was out of sync and should now be ready |
Continuation of #58931.
Updated after rebasing on top of #59553 as the two had some compatibility issues (and that PR took precedence). Has now been updated to be compatible, and also incorporated the comments @reduz left on #58931. Most notably, the sorting logic is now in the editor code where it belongs.
Closes godotengine/godot-proposals#4189
Closes godotengine/godot-proposals#99
Please read above proposal for more info and some example of what code completion currently looks like.
After changes in this PR:
Code Overview:
ScriptCodeCompletionOption
. It is an int, but has a corresponding enum, and more importantly one of the enum values is a mask, LOCATION_PARENT_MASK = (1 << 8),. This allows you, for example, to sort closer ancestors differently from more distant ancestors. The class itself will be value 256, while the class it inherits will have its location at 257, and then its parent at 258, etc.const int location = classes_processed | ScriptCodeCompletionOption::LOCATION_PARENT_MASK;
ScriptCodeCompletionOption::Kind
's are sorted has been added too.