[patch] open folds on horizontal movements

15 views
Skip to first unread message

Christian Brabandt

unread,
May 20, 2012, 8:45:08 AM5/20/12
to vim...@vim.org
Bram,
I find it irritating, that folds open on horizontal movements depending
on where the cursor is.

For example open fold.c, move the cursor to a closed fold, Move the
cursor to the end of the line ('$'), now the fold opens. Close the fold
and press 'l'. The closed fold does not open, because the cursor did not
move.

This happens sometimes to me and I find this confusing, that
sometimes the fold does not open and sometimes it does.

So here is a small patch, that fixes it.

diff --git a/src/normal.c b/src/normal.c
--- a/src/normal.c
+++ b/src/normal.c
@@ -6081,7 +6081,7 @@
#endif
}
#ifdef FEAT_FOLDING
- if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped
+ if (n <= cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped
&& cap->oap->op_type == OP_NOP)
foldOpenCursor();
#endif
@@ -6151,7 +6151,7 @@
}
}
#ifdef FEAT_FOLDING
- if (n != cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped
+ if (n <= cap->count1 && (fdo_flags & FDO_HOR) && KeyTyped
&& cap->oap->op_type == OP_NOP)
foldOpenCursor();
#endif


regards,
Christian
--
Uns selbst zu achten, leitet unsre Sittlichkeit; andere zu
schätzen, regiert unser Betragen."
-- Goethe, Maximen und Reflektionen, Nr. 171

Bram Moolenaar

unread,
May 20, 2012, 2:05:00 PM5/20/12
to Christian Brabandt, vim...@vim.org
I'm not sure we need this change. It's actually not because the cursor
didn't move. If you use a command that fails, such as using "l" when
already at the end of the line, nothing happens. If you want to open a
fold intentionally, use "0", that never fails. Is there a good reason
to change this behavior?


--
BEDEVERE: Wait. Wait ... tell me, what also floats on water?
ALL: Bread? No, no, no. Apples .... gravy ... very small rocks ...
ARTHUR: A duck.
"Monty Python and the Holy Grail" PYTHON (MONTY) PICTURES LTD

/// Bram Moolenaar -- Br...@Moolenaar.net -- http://www.Moolenaar.net \\\
/// sponsor Vim, vote for features -- http://www.Vim.org/sponsor/ \\\
\\\ an exciting new programming language -- http://www.Zimbu.org ///
\\\ help me help AIDS victims -- http://ICCF-Holland.org ///

Christian Brabandt

unread,
May 20, 2012, 2:10:21 PM5/20/12
to vim...@vim.org
Hi Bram!
The point is, when the folds are closed, the user doesn't know, whether
the cursor is at the end of the line so it's kind of unexpected that l
doesn't open the fold.

regards,
Christian
Reply all
Reply to author
Forward
0 new messages