godotengine / godot-proposals

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

F1 Search Help reused to navigate code: show custom symbols without doc + go to source code of custom class/method (from F1 popup or documentation) #9095

Open hsandt opened 8 months ago

hsandt commented 8 months ago

Describe the project you are working on

A platformer

Describe the problem or limitation you are having in your project

I often use F1 to search my custom methods like "Go to symbol..." command in other code editors, but I realized that it's really meant for documentation:

While a separate Go To method would be great, I figured we could reuse the existing F1 search for symbol navigation to custom symbols (since native symbols would require linking to C++ files, only available when building Godot, and it would be more complex). This way users would be able to see both class/method descriptions and source code easily.

Also, for this to work well, we should list all custom symbols, even those without a doc comment. Otherwise the trick is to add just ## in front of every symbol (without any text), since it will add them to the F1/doc list with the text:

There is currently no description for this method.

which means an empty documentation is actually already supported, but we want to avoid the ## trick.

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

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

F1 window:

F1 window with button to go to source

Documentation tab: Doc tab with buttons to go to source

Forgive the "HTML code" icon I used, you can pick any icon you think is fit (maybe just <> like GitHub)

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

No

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

It affects native windows directly.

Mickeon commented 8 months ago

The idea is not bad. Problem is, this button for every definition would be extremely overkill and prone to clutter the class reference and help search alike.

I would propose a "right-click" popup menu but that would come at the cost of accessibility. At the same time, however, I'm not sure how vital this feature is and if it warrants being more visible than that.

hsandt commented 2 months ago

I'll also refer to modifier+click mentioned in https://github.com/godotengine/godot-proposals/discussions/5643 then:

For example, Ctrl+Click opens the documentation, Ctrl+Shift+Click (or maybe Alt+Click) opens the definition.

which is also a hidden way, though.

We could also have a completely different popup such to open source code, Go To Symbol (as in other IDE). We'd always have a separate shortcut to Go to Definition of method under cursor/caret so it'd be easy to navigate from definition to doc (but to navigate from doc to definition we'd still need either a button or contextual menu or modifier click in the doc...)

Hm, I should have probably continued the linked discussion before opening a proposal, so we could set on one implementation. Never mind, we can continue the discussion here or on the other thread and if we settle on another implementation, I'll just open another proposal instead.