SublimeText-Markdown / MarkdownEditing

Powerful Markdown package for Sublime Text with better syntax understanding and good color schemes.
MIT License
3.17k stars 649 forks source link

Problems with folding #727

Closed glow12121 closed 1 year ago

glow12121 commented 1 year ago

I am observing several problems with folding markdown sections.

This is the source text:

image

Then I fold the ### sections using this hoykey: { "keys": ["ctrl+shift+["], "command": "fold" },

This is the outcome:

image

I believe the following are flaws here:

deathaxe commented 1 year ago

In the folded condition, there is no empty line in-between ### sections

Maybe a question of taste, but this is the style MarkdownEditing has always used to fold headings/sections. Should be easy to tweak, but I don't want to add settings for that and most (all other) users seem to be fine with current state.

Folding eats up the -------- dividing line, ...

Both syntax based folding rules and plugin based folding feature are designed to fold regions between headings. So this is working as expected.

There are no little arrows or smth. like this, to fold/unfold with a mouseclick.

MarkdownEditing ships basic syntax based folding rules, which should enable ST to draw fold buttons next to headings.

grafik

Note

Fold buttons are displayed only, if ST detects foldable regions via indentation levels or via folding rules. The latter one and thus fold buttons next to headings are enabled only if "fold_style" is set to "auto" or "scope_only".

Beyond that MarkdownEditing has shipped plugin based folding features for ages. Started with long before syntax based folding was added to ST's set of core features. As there's no API to announce foldable reagions or to interact with fold buttons, key bindings are all plugins can use. ST doesn't display fold buttons until a folded region is detected, if it hasn't found foldable regions on its own.

MarkdownEditing overrides default fold/unfold key bindings to provide an as consistent as possible UX compared to ST's default behavior.

Current state of ST's syntax based folding engine is insufficient to replace plugin code, completely.

Note

Syntax based folding (via buttons) and plugin based folding (via key bindings) may behave a little bit different for historic reasons and because of different philosophy with regards how sections between headings are intendet to be folded. Syntax based folding is to naive to support all features, plugin can do.

glow12121 commented 1 year ago

Maybe a question of taste, but this is the style MarkdownEditing has always used to fold headings/sections. Should be easy to tweak, but I don't want to add settings for that and most (all other) users seem to be fine with current state.

Thanks for the reply.

Folding is literally the main thing I need from the plugin and this style of folding seems very counter-intuitive. In markdown, empty lines are what creates separate paragraphs. Are there ways for me to tweak this?

Also, how can this little triangle on the left be enabled?

image

deathaxe commented 1 year ago

Folding doesn't work "per paragraph" and there's no way to tweak it.

glow12121 commented 1 year ago

I didn't ask about folding per paragraph -- but about keeping empty lines in-between folded sections.

The questions about the little mysterious triangles remains, too.

deathaxe commented 1 year ago

To enable fold buttons, set "fold_style" to "auto" or "scope_only" in Preferences - assuming ST 4145+.

Otherwise, I can't say something about it. Basic syntax specific folding rules are provided, so folding buttons should appear in ST 4143+. If not, maybe a core issue. Works fine on Win11 with MarkdownEditing being the only package installed in ST running in SAFE MODE.

glow12121 commented 1 year ago

A. Oh well, in ST 4143 on Linux, these little triangles are seemingly not there.

B. If it is somehow possible to keep a distance in-between the folded headlines, please let me know.

image

glow12121 commented 1 year ago

In the case of the little arrows on the left margin, I have figured out what was the problem. I had "gutter": false, which, naturally, made it impossible for the little arrows to be displayed.

image

Also, for some reason there's now an empty line in-between headlines. Have no idea why but, to me, it looks nice.

Anyway, thanks to the devs for trying to guide me through this and for maintaining the plugin.

glow12121 commented 1 year ago

Why I think there should be an empty line in-between folded headlines by default -- because in Markdown an empty line is what creates a paragraph. No empty line is counter-intuitive. It looks out of tune too.