godotengine / godot-proposals

Godot Improvement Proposals (GIPs)
MIT License
1.16k stars 97 forks source link

Script Panel / Methods List: add foldable preview to methods #8082

Open inhalt120g opened 1 year ago

inhalt120g commented 1 year ago

Describe the project you are working on

A classic arcade game, but it applies to any kind of project

Describe the problem or limitation you are having in your project

I often want to look at a particular function ("method") while comparing to how it's actually used, in other words, what does the function do with the code it's surrounding it.

Most often the function is defined somewhere towards the bottom of the script, while the code where it's called and where the parameters etc are defined are somewhere far away. So if I want to look at one and compare it step by step with the other, I have to constantly jump and switch between two distant places, which is impractical.

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

It'd be useful if each function in the list would have a foldable preview, which could be unfolded and (since it's in the Script Panel) stay like it's set, while I scroll through the rest of the code in the main window and go through whatever has to be checked.

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

This is what the list looks at the moment, let's say I want to inspect the "start" part and how it relates to some code elsewhere: image

if the functions were foldable, maybe marked like this: image

and for example if I clicked on the triangle next to "Start", it'd open like this: image

and then in the main window on the right I can scroll wherever and follow what exactly is happening there while the "start" on the left stays unfolded for easy comparison.

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

This is about the script

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

I don't know how can it be an add on.

KoBeWi commented 1 year ago

So if I want to look at one and compare it step by step with the other, I have to constantly jump and switch between two distant places, which is impractical.

That's what bookmarks are for. You still need to jump, but they make it easier.

inhalt120g commented 7 months ago

@KoBeWi There was a misunderstanding, I think I haven't explained it properly.

You still need to jump, but they make it easier.

But jumping is precisely what I'm trying to avoid. In the current system, using bookmarks makes the code window jump to whatever is the position of the bookmark. So comparing two functions means having to constantly jump between two places. (And of course if you have a few bookmarks it can get fiddly.) But this won't allow you to see both functions at the same time, you'll just have to keep one of them in your head for some amount of time.

The goal of the proposal is to eliminate jumping, and instead make it easier to keep a function visible (or at least its representative preview) while freely scrolling the code in the code editor to other parts of the code.

So for example if the code were 1000 lines long and I wanted to compare how two functions interact… if the first function is occupying lines 100-110 and the second function is at 500-510, in the current system I can't see both of them at the same time.

But if I could "unfold" the first function in the preview window, then switch to the code editor and scroll down to lines 500~510, I could see both.