Supported commands are: za / zo / zc toggle / open / close fold on one level of folding zA / zO / zC toggle / open / close fold on all folding levels zR / zM open / close all folds You can view, comment on, or merge this pull request online at:
https://github.com/geany/geany-plugins/pull/1327
-- Commit Summary --
* Implement fold in vimode plugin
-- File Changes --
M vimode/src/cmd-runner.c (9) M vimode/src/cmds/edit.c (45) M vimode/src/cmds/edit.h (12)
-- Patch Links --
https://github.com/geany/geany-plugins/pull/1327.patch https://github.com/geany/geany-plugins/pull/1327.diff
Looks good in general, but I think folding should work when the cursor is anywhere in the block, not just on the fold point (vim seems to work this way). I played with it a little and came up with something like this: ```C static gint prepare_fold(CmdParams *p) { /* foldparent of the next line */ gint line = SSM(p->sci, SCI_GETFOLDPARENT, p->line + 1, 0);
if (p->line == line) ; /* we are already on the fold point line */ else { /* foldparent of the current line */ line = SSM(p->sci, SCI_GETFOLDPARENT, p->line, 0); }
if (line != -1) { /* move the cursor on the visible line before the fold */ gint pos = SSM(p->sci, SCI_POSITIONFROMLINE, line, 0); SET_POS_NOX(p->sci, pos, TRUE); }
return line; }
void cmd_toggle_fold(CmdContext *c, CmdParams *p) { gint line = prepare_fold(p); if (line != -1) SSM(p->sci, SCI_FOLDLINE, (uptr_t) line, SC_FOLDACTION_TOGGLE); } ```
If the code looks OK to you and works as expected, could you update all the folding functions similarly to `cmd_toggle_fold()` above?
In addition, these aren't exactly "edit" commands and should be placed in a separate file. Could you create `fold.c/h`, add them to `Makefile.am` and move all these commands there?
github-comments@lists.geany.org