vimish-fold icon indicating copy to clipboard operation
vimish-fold copied to clipboard

Edit fold names

Open LuchoEskimo opened this issue 6 years ago • 4 comments

I really like vimish-fold, but something annoys me: when a region is folded, I can't edit its first line. When the region is the last part of the buffer, it prevents me from adding a new line. Also, using command such as comment-dwim (which comments a region) isn't possible for the whole file: I get the message comment-region-default: Text is read-only. How could I edit fold names ?

LuchoEskimo avatar Jul 25 '17 07:07 LuchoEskimo

when a region is folded, I can't edit its first line

This is not its first line, it's like a hint of what the fold contains. To edit it you need to unfold it, which makes sense IMO, because you'll be able to see the whole text in normal form.

When the region is the last part of the buffer, it prevents me from adding a new line.

I can't reproduce it here. If I fold several last lines in a buffer, I still can position cursor after the fold and execute either newline or open-line. Maybe it's because my files always end with a newline?

Also, using command such as comment-dwim (which comments a region) isn't possible

This is same idea, you first unfold, then edit. I understand it may be annoying, but the read-only property is there for a reason. It would be too easy to end up with folds that look bad (i.e. fold overlay starts not from beginning of a line but somewhere in the middle) without it.

mrkkrp avatar Jul 29 '17 07:07 mrkkrp

I now understand your vision of folds! For the second issue, consider the following file

Fold 1
some text
Fold 2
some text

where lines 1 and 2 are folded together as well as lines 3 and 4. Then, folding all gives something looking like

| Fold 1                                                    2 lines
| Fold 2                                                    2 lines

Now if you want to add something between the two fold, you would naturally position the cursor at the beginning of line 3 (line with Fold 2) and hit <enter>. However, this can't be achieved because text is read-only. Then, you would position the cursor at the end of the first line, after the s of 2 lines, expecting to be able to press <enter> and be able to type text between the two folds: it doesn't work either.

This kind of edits of the name of a fold (that is, just inserting a line before or after a fold) couldn't mess up with the organisation of folds, so I think they should be allowed!

LuchoEskimo avatar Jul 31 '17 07:07 LuchoEskimo

Yes, I see the problem, but I don't know yet how to solve it.

mrkkrp avatar Jul 31 '17 09:07 mrkkrp

Perfect, thank you!

LuchoEskimo avatar Jul 31 '17 14:07 LuchoEskimo