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

Implement Editor Settings for autocomplete with StringNames and NodePaths #5496

Closed
MewPurPur opened this issue Sep 26, 2022 · 9 comments · Fixed by godotengine/godot#66481
Closed
Milestone

Comments

@MewPurPur
Copy link

MewPurPur commented Sep 26, 2022

Describe the project you are working on

A 2D platformer, recently started using NodePaths and StringNames where I can.

Describe the problem or limitation you are having in your project

Autocomplete tools and similar are not respectful of my wishes.

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

After implementing godotengine/godot#66332 I realized we don't actually have any consistent way to tell the editor when we want to use NodePaths or StringNames.

Naturally, both should be editor settings. They would affect autocomplete and dropping properties in editor and cause them to use the NodePath literal ^ and StringName literal &.

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

Simply append the literals at the beginning of the string when the setting is enabled.

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

Not possible

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

Dunno, seems too basic to not be in core, given NodePaths and StringNames are so easy to use.

@Mickeon
Copy link

Mickeon commented Sep 26, 2022

After this setting I suppose it would make sense to refactor autocompletion to take it into account, because for example:
image

This is technically slower but it's much, so much easier to grasp for beginners. With the setting enabled, these would display with the ^ prefix.

@MewPurPur
Copy link
Author

That's the main thing the proposal aims to solve. I think the settings should be off by default.

@KoBeWi
Copy link
Member

KoBeWi commented Sep 26, 2022

I think the names in autocompletion should just be unquoted:
image
And only add "^& after accepting.

@MewPurPur
Copy link
Author

MewPurPur commented Sep 27, 2022

I'm currently working on this proposal btw, I think I'll be able to finish it.

Edit: 🎉

@MewPurPur
Copy link
Author

MewPurPur commented Sep 27, 2022

@KoBeWi Didn't implement that, so the PR stays focused on more advanced autocompletion. I think removing the quotation marks would be controversial, or warrant a setting of its own. I would personally rather not be misguided about exactly what autocompletion will do. Only for things like braces after methods I think it's acceptable to not show the full thing, because they are in front of everything, so the user first autocompletes, then thinks about adding braces. But quotation marks are added first, not last. With your idea, I can see a lot of people adding strings thinking autocomplete won't sort it out for them.

@KoBeWi
Copy link
Member

KoBeWi commented Sep 27, 2022

I mean, I attached an actual screenshot from 3.5. Signals display this way and so far no one complained.

@Mickeon
Copy link

Mickeon commented Sep 27, 2022

image

I need to see and understand how code completion works for these more hard-coded options because it's not just a matter of appending a String. The signal symbol to the left and the lack of quotes, which are added only afterwards...

@MewPurPur
Copy link
Author

MewPurPur commented Sep 27, 2022

@Mickeon There is an autocompletion options struct, which has a string for what's shown and another string for what's gonna actually be filled. Idk how it's in 3.5 though.

My PR dances around those areas of autocompletion, you can check it out. In code_edit.cpp specifically

@Mickeon
Copy link

Mickeon commented Sep 27, 2022

Oh that I'm aware. The question was more about, what actually assigns these specifically hardcoded options (e.g. the signals in 3.x, or a list of Nodepaths when inputting "$"). Because that part may be the one needing of some refactoring, to more tidily account for this Proposal's feature.

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