sublimehq / sublime_text

Issue tracker for Sublime Text
https://www.sublimetext.com
804 stars 39 forks source link

Remember nested folding state #1815

Open evandrocoan opened 7 years ago

evandrocoan commented 7 years ago

Summary

Sublime Text cannot remember nested folding state.

Expected behavior

When unfolding the parent fold, it is expected to its children folds be remembered.

Actual behavior

When unfolding the parent fold, its children folds state are forgotten/lost.

Steps to reproduce

  1. Create the text:

    Fold next
        I am danm folded
        I am danm folded
        I am danm folded
    
        Nested folding state
            I am danm folded
            I am danm folded
            I am danm folded
  2. Fold the children and the parent indents.
  3. Unfold the parent.
  4. It is expected to its child to be folded, but it is not.

Imgur

Environment

ghost commented 7 years ago

Duplicate/related to https://github.com/SublimeTextIssues/Core/issues/1175. Feel free to close the issue started by me, since this one has a screencast.

FichteFoll commented 7 years ago

I prefer this over the other, because it more clearly describes what is needed ("remembering nested fold states" rather than "unfold one level at a time").

xPh03n1x commented 5 years ago

+1 from me on this.

Although the issue has a Minor label, I believe this is rather important for anyone using Sublime with a heavily stacked code.

I've been struggling for weeks with this as I am working on a deeply nested codebase. Code folding on inner levels has become rather pointless since once you fold & unfold the parent - it's gone.

Please implement this!

pjmattingly commented 5 years ago

Yes, I have a similar problem. I work with text with quite a lot of nested indents which are lost of folding / unfolding the top level line.

Please implement! Thank you.

Ithiloneth commented 3 years ago

+1 here!

This feature is very useful for non-code uses as well. I like to use Sublime Text to write "interactive text documents" - using nesting to create headers/sub-headers to make a document very easy to navigate on just a small area of the screen even when there is a lot of text in it.

Please enable some sort of persistence for nested code folding, or even just a modifier key to let us unfold just the one block and not it's children.

lenerdv2005 commented 3 years ago

This is really the only major problem with sublime, and I'm surprised that it's been open for 4 years now and still not addressed. This would be a life saver for a good chunk of the community. Please add this!

Zero4793 commented 3 years ago

+1 here I'm new to this, is the +1 here how i upvote? Yeah, i really wish folding was remembered, or at the very least, defaulted to folded. Ideal is that the child states are remembered, but if we don't get that I'd prefer to manually unfold what i need, then to manually refold all that i don't need.

Ithiloneth commented 3 years ago

The following does not resolve the issue, but it may band aid the situation for some!

I have been using AutoFoldCode - a package which remembers the fold state on exit and then reapplies that state when Sublime text is run.

It is not flawless, but I've had a good experience using it for some time now!

https://packagecontrol.io/packages/AutoFoldCode

oversword commented 3 years ago

How has this not been fixed? Code folding is effectively useless without this feature

henvu50 commented 3 years ago

I was about to switch from Notepad++ to Sublime Text, but not resolving this issue is a deal breaker.

Does anyone know of a plugin for sublime text that resolves the catastrophic issue explained in the issue up above?

pjmattingly commented 3 years ago

No, nothing really works.

I switched from notepad++ to sublime because notepad++ didn't work with very large files (multi-metabyte). I still miss their way of handling code folding. =/

On Thu, Jun 3, 2021 at 1:54 PM henvu50 @.***> wrote:

I was about to switch from Notepad++ to Sublime Text, but not resolving this issue is a deal breaker.

Does anyone know of a plugin for sublime text that resolves the catastrophic issue explained in the issue up above?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sublimehq/sublime_text/issues/1815#issuecomment-854136217, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABP7MZ32HTGO7T2FKG3XJKLTQ7MWHANCNFSM4DTB4BUA .

henvu50 commented 3 years ago

i'm currently trying ultraedit to see if it can fold text. i can't eblieve something so fucking simple has not been solved yet, i'm so pissed On Thursday, June 3, 2021, 01:08:40 PM PDT, pjmattingly @.***> wrote:

No, nothing really works.

I switched from notepad++ to sublime because notepad++ didn't work with very large files (multi-metabyte). I still miss their way of handling code folding. =/

On Thu, Jun 3, 2021 at 1:54 PM henvu50 @.***> wrote:

I was about to switch from Notepad++ to Sublime Text, but not resolving this issue is a deal breaker.

Does anyone know of a plugin for sublime text that resolves the catastrophic issue explained in the issue up above?

— You are receiving this because you commented. Reply to this email directly, view it on GitHub https://github.com/sublimehq/sublime_text/issues/1815#issuecomment-854136217, or unsubscribe https://github.com/notifications/unsubscribe-auth/ABP7MZ32HTGO7T2FKG3XJKLTQ7MWHANCNFSM4DTB4BUA .

— You are receiving this because you commented. Reply to this email directly, view it on GitHub, or unsubscribe.

henvu50 commented 3 years ago

Guys, my apologies for using foul language. That was actually from an email I sent, but it somehow ended up here! I did not type that foul language here. Apologies.

thoran commented 1 year ago

Guys, my apologies for using foul language. That was actually from an email I sent, but it somehow ended up here! I did not type that foul language here. Apologies.

We should not diminish those who care about their tools or craft. It shows passion!

thoran commented 1 year ago

I found this issue when looking for a whether a bug has been reported in the cmd-K, cmd- bug I found recently. I have to admit that I have noticed this issue, but didn't worry about it, because I found that it was sufficient to get handy with cmd-K, cmd-, but how that that's not working as reliably, it means that there is not fallback as a resolution to this bug or feature not present would be.

Aelay commented 1 year ago

Also really need this

leobianco commented 1 year ago

It is hard to believe that an editor this powerful does not support this feature (and for so long).

LukeDickerson19 commented 1 year ago

+1, switching to Obsidian for note taking solely for this feature. Obsidian lacks a lot of stuff Sublime has though, so I'll switch back if implemented.

mattcrichards commented 11 months ago

+1 Please consider implementing!

Zero4793 commented 11 months ago

+1, switching to Obsidian for note taking solely for this feature. Obsidian lacks a lot of stuff Sublime has though, so I'll switch back if implemented.

I first left sublime in favour of the free and more popular vscode. then i've more recently moved note taking to obsidian, and kept code with vscode. i now only use sublime very rarely. and i remember one of the features of sublime i prefered over vscode was the auto complete. But i believe they changed it to be more inline with the common way of doing it which i dislike.

xPh03n1x commented 11 months ago

Guys, it's been 6 YEARS !

This is part of almost all (if not all) other IDEs out there. This is achievable through a plugin, so it's definitely not something hard or super time consuming to implement from your end, right into the official release.

6 years is enough time to ignore something major like this! Time to remove that "minor" tag and spend a couple of days working on this (and I know for a fact it's not going to take more than that, my own plugin which does this took me less than 2 work days)

mattcrichards commented 11 months ago

@xPh03n1x - Is your plugin publicly available? I'd love to use it!

xPh03n1x commented 11 months ago

@mattcrichards

@xPh03n1x - Is your plugin publicly available? I'd love to use it!

Too bad I didn't see your message earlier. I got annoyed by Sublime and after I saw that VS Code does everything I need - I just deleted my Sublime directly, including the themes and plugins I had.

I am not going back to Sublime for sure.

mattcrichards commented 11 months ago

I appreciate the response!

On Fri, Oct 20, 2023 at 9:31 AM John Jamesson @.***> wrote:

@xPh03n1x https://github.com/xPh03n1x - Is your plugin publicly available? I'd love to use it!

Too bad I didn't see your message earlier. I got annoyed by Sublime and after I saw that VS Code does everything I need - I just deleted my Sublime directly, including the themes and plugins I had.

I am not going back to Sublime for sure.

— Reply to this email directly, view it on GitHub https://github.com/sublimehq/sublime_text/issues/1815#issuecomment-1772851673, or unsubscribe https://github.com/notifications/unsubscribe-auth/ATWJSEUB43MHYNK5DAZU3I3YAKDLLAVCNFSM4DTB4BUKU5DIOJSWCZC7NNSXTN2JONZXKZKDN5WW2ZLOOQ5TCNZXGI4DKMJWG4ZQ . You are receiving this because you commented.Message ID: @.***>

LukeDickerson19 commented 11 months ago

It would be cool if github automatically prioritized issues based on number of comments, and general activity. I'd take it a step further and pay developers per issue/ticket instead of salary/hourly.

ryuukk commented 9 months ago

i am annoyed AF that it is not supported

if anyone have a python script for this feature please share, i'm not going to invest time doing it myself

i'm tired and want to focus on working on my game instead of being a free worker

image

ryuukk commented 9 months ago

Actually.. i'll try to make a plugin for it, i'll fight for great features, i'll share it here

LukeDickerson19 commented 9 months ago

Neither sublime or obsidian ended up having this feature for me. VS code + the Project Manager extension has it though.

AndrePssoa commented 9 months ago

@ryuukk Any updates? Is it really possible to change the folding behaviour via a plugin?

evandrocoan commented 9 months ago

There is an API, but from my experimentation with it, it has the same problem as the builtin fold command: https://www.sublimetext.com/docs/api_reference.html

>>> view.fold(sublime.Region(5, 8))
True
>>> view.fold(sublime.Region(5, 8))
False
>>> view.unfold(sublime.Region(5, 8))
[Region(5, 8)]
>>> view.unfold(sublime.Region(5, 15))
[]
>>> view.fold(sublime.Region(5, 15))
True
>>> view.fold(sublime.Region(5, 20))
True
>>> view.fold(sublime.Region(5, 32))
True
>>> view.unfold(sublime.Region(25, 30))
[Region(14, 46)]

For it to work, your plugin would have to keep track of which regions were folded and refold them back when sublime unfolded everything, but there is no event lister for the fold event for you to keep track of. You would need to add a custom gutter icon action to override the default fold button, but I wonder if you can add a custom gutter button for the user to click. Perhaps fold by a keybind and use the user selection, but there is no way to detect when the user hits the unfold button so your plugin can refold back. You could also use two key binds, one to fold and another to unfold under the selection, but it would be awkward to fold and unfold by selection and key binds.

Some related topics to gutter:

  1. https://forum.sublimetext.com/t/gutter-button-or-fold-by-scope/19652
  2. https://forum.sublimetext.com/t/hover-click-events-in-gutter/20747/
willrowe commented 8 months ago

I've been using BufferScroll for years.

AndrePssoa commented 8 months ago

@willrowe Correct me if i'm wrong, but BufferScroll is designed to save the "folding state" of the code, so when we close the file and reopen it, the plugin will restore all folded regions.

That's not what this issue is about. We actually want to change the behavior of the fold/unfold commands, to use it WHILE CODING, not while closing and reopening files.

You can check Notepad++'s implementation of the fold/unfold functionality as a perfect example of what we want (the code unfolds step-by-step, instead of unfolding all children at once).

willrowe commented 8 months ago

@AndrePssoa you are correct, I misunderstood the part about nesting. BufferScroll only remembers the top level.