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

Improve dragging items from Scene Preview into source code #661

Merged
merged 9 commits into from
Jun 29, 2024

Conversation

iMarv
Copy link
Contributor

@iMarv iMarv commented May 24, 2024

Commit message:

The right-click action, that drops the node-path into your clipboard already provides close to the same utility of the drag-n-drop feature - only missing a `$`.
To complement this and to add another QoL change, I refactored the drop-edit functionality to include a full `@onready` template. This will now create a variable name based on the node-name and provides the full convention, inspired by the same feature in the godot editor: https://github.com/godotengine/godot-proposals/issues/4482

The mentioned feature in the godot editor by default drops the $-import aswell, but allows dropping a full onready template when holding ctrl.
As far as I understand, VsCode does not allow fetching which keys the user may be pressing, so duplicating this feature 1:1 is not possible.

The extension already has amazing support for autocompleting $-imports in intellisense, so for me a big timesaver would be to be able to drag-n-drop the entire onready statement from the scene tree.

I have added this change as a reference implementation in this Pull Request. As far as I understand, there is no equivalent to this in C#, so I left the GetNode string there untouched.

Is this a feature to consider as the default? If not, would you be open to add it as a config option to the app?

iMarv and others added 2 commits May 24, 2024 11:55
The right-click action, that drops the node-path into your clipboard
already provides close to the same utility of the drag-n-drop feature -
only missing a `$`.
To complement this and to add another QoL change, I refactored the
drop-edit functionality to include a full `@onready` template. This will
now create a variable name based on the node-name and provides the full
convention, inspired by the same feature in the godot editor: godotengine/godot-proposals#4482
@DaelonSuzuka
Copy link
Collaborator

How about this:

Code_ltaV0QOWrx

@DaelonSuzuka DaelonSuzuka marked this pull request as ready for review June 24, 2024 22:20
@iMarv
Copy link
Contributor Author

iMarv commented Jun 25, 2024

🤯 great Idea
I also discovered that the Godot Editor supports this for uniquely named Nodes, which I would like to add in the next couple days aswell

@iMarv
Copy link
Contributor Author

iMarv commented Jun 26, 2024

Added behavior for % syntax and also a few comments on why we check for the empty line there

@DaelonSuzuka
Copy link
Collaborator

Good idea, I'll check it out later today.

Do you mind taking a look at what happens when you drag the root node of a scene into the editor? I was getting this yesterday:

Code_JyOLsccST4

Which is definitely not useful.

@iMarv
Copy link
Contributor Author

iMarv commented Jun 27, 2024

Will do. I am not too experienced with VsCode extensions - how would we test this automatically? It feels like the edgecases are starting to pile up and I would feel more comfortable with my changes if I would add a few tests on them

iMarv and others added 4 commits June 27, 2024 14:02
Originally, we used and split the path of a node to get its name. This
ran into issues with the root-node of a scene though, as a root node has
no path. This logic has been replaced by directly getting the name of
the node from its `label` attribute, which is now passed directly to the
drag handler.
@DaelonSuzuka
Copy link
Collaborator

This extension does have a test suite, but I have no idea how to programmatically invoke behavior like dragging and dropping.

Personally, I think what we have here is extremely straightforward and doesn't really need testing anyways.

@iMarv
Copy link
Contributor Author

iMarv commented Jun 28, 2024

Alright then, not going to start a religious discussion on that 😄
For me this looks "feature complete" now, I have nothing else to add.

@DaelonSuzuka
Copy link
Collaborator

DaelonSuzuka commented Jun 28, 2024

Sounds good. I'll review this again later today and probably merge it.

Thanks for starting this feature, I think it's a solid upgrade!

@DaelonSuzuka DaelonSuzuka changed the title Change scene dropEdit from $-import to @onready template Improve dragging items from Scene Preview into source code Jun 29, 2024
@DaelonSuzuka DaelonSuzuka merged commit 6456a78 into godotengine:master Jun 29, 2024
4 checks passed
@iMarv iMarv deleted the onready-drag branch June 30, 2024 08:31
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.

3 participants