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

Make fold/unfold line shortcut work anywhere within a foldable section, not just on the line with the folding marker #5061

Open
just-like-that opened this issue Aug 2, 2022 · 8 comments

Comments

@just-like-that
Copy link

just-like-that commented Aug 2, 2022

Describe the project you are working on

2D-game - any will do

Describe the problem or limitation you are having in your project

Currently folding "Fold/Unfold Line" of a single function works via shortcut if the user is positioned at the head of the function only.

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

Add support for folding if cursor is placed anywhere in function to omit that I've to scroll to the beginning of (long) functions first.

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

If "Fold Line" (Alt-F) is pressed inside a function body it folds the method like it does at the head of the function, too.

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

Existing editor feature.

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

Improving an existing script editor feature.

@Calinou Calinou changed the title Script Text Editor: enhancement of fold/unfold line to work everywhere in function NOT just on header line. Make fold/unfold line shortcut work anywhere within a foldable section, not just on the line with the folding marker Aug 2, 2022
@vivienprouvot
Copy link

Hi,
As I'm trying to get all my code in one single folder for my personnal readibility, I'm also very interested in such a fonctionality. Would you know if there is any way to modify the file itself (or the project file) in order to do so ?
Thank you.

@Calinou
Copy link
Member

Calinou commented Jan 3, 2023

This is the code that is called when using the Fold Line shortcut: https://github.com/godotengine/godot/blob/26bed8aa85fc2f98e38552a82929e1deb5b29d8a/scene/gui/code_edit.cpp#L1637-L1644

You will need to modify it to allow folding from anywhere, then recompile the editor source code to test your changes.

@vivienprouvot
Copy link

Hmmm just above the lines you mentioned, there is this function : fold_all_lines, maybe it is already implemented yet ? (Maybe it is what you suggested when you say "from anywhere"...)

Also, line 2272 there is this : ClassDB::bind_method(D_METHOD("fold_all_lines"), &CodeEdit::fold_all_lines);
But I can't figure what &CodeEdit:: really is.

@Calinou
Copy link
Member

Calinou commented Jan 26, 2023

But I can't figure what &CodeEdit:: really is.

This line binds the "fold_all_lines" method (from the scripting API) to a reference to the fold_all_lines() method of the CodeEdit class in C++.

@vivienprouvot
Copy link

Hi everyone.
I am still interested in this functionality but as I am a poor developer, I'm not sure I could imagine a pull/request.
Also, I'd like to mention since I switched to linux, this Alt+F shortcut dosn't work to unfold.
I tried to change it to another shortcut but the behavior is the same : it writes the letter on the screen instead of unfolding the line.
Anyone willing to help ? =]

@vivienprouvot
Copy link

I don't know since when it is available, but it is.
Thank guys, you do amazing work. Libre softwares are the future ;)

@Calinou

This comment was marked as outdated.

@Calinou Calinou closed this as completed May 6, 2024
@Calinou Calinou added this to the 4.0 milestone May 6, 2024
@kitbdev
Copy link

kitbdev commented May 6, 2024

Maybe @vivienprouvot is referring to their previous comment about the shortcut not working on Linux?
I'm not sure, but this is not implemented yet, so this should be reopened.

@Calinou Calinou reopened this May 6, 2024
@Calinou Calinou removed this from the 4.0 milestone May 6, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

4 participants