Skip to content

Commit 33984ab

Browse files
committed
vimode: Ensure that the line with the cursor is expanded after performing a command
Without this, using e.g. 'w' to go to the next word makes the cursor go "inside" the fold and disappear. Vim seems to auto-expand the fold in such situations so do the same.
1 parent 522b79d commit 33984ab

File tree

4 files changed

+12
-0
lines changed

4 files changed

+12
-0
lines changed

vimode/src/cmd-runner.c

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -704,6 +704,7 @@ static gboolean process_cmd(CmdDef *cmds, CmdContext *ctx, gboolean ins_mode)
704704
{
705705
if (orig_mode == VI_MODE_COMMAND_SINGLE)
706706
vi_set_mode(VI_MODE_INSERT);
707+
ensure_current_line_expanded(ctx->sci);
707708
}
708709
else if (!consumed && ctx->kpl)
709710
{

vimode/src/excmd-runner.c

Lines changed: 2 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -465,6 +465,7 @@ void excmd_perform(CmdContext *ctx, const gchar *cmd)
465465
{
466466
case ':':
467467
perform_simple_ex_cmd(ctx, cmd + 1);
468+
ensure_current_line_expanded(ctx->sci);
468469
break;
469470
case '/':
470471
case '?':
@@ -483,6 +484,7 @@ void excmd_perform(CmdContext *ctx, const gchar *cmd)
483484
pos = perform_search(ctx->sci, ctx->search_text, ctx->num, FALSE);
484485
if (pos >= 0)
485486
SET_POS(ctx->sci, pos, TRUE);
487+
ensure_current_line_expanded(ctx->sci);
486488
break;
487489
}
488490
}

vimode/src/utils.c

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -219,3 +219,11 @@ void goto_nonempty(ScintillaObject *sci, gint line, gboolean scroll)
219219
pos = NEXT(sci, pos);
220220
SET_POS(sci, pos, scroll);
221221
}
222+
223+
224+
void ensure_current_line_expanded(ScintillaObject *sci)
225+
{
226+
gint line = GET_CUR_LINE(sci);
227+
if (!SSM(sci, SCI_GETLINEVISIBLE, line, 0))
228+
SSM(sci, SCI_ENSUREVISIBLE, line, 0);
229+
}

vimode/src/utils.h

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -32,5 +32,6 @@ void perform_substitute(ScintillaObject *sci, const gchar *cmd, gint from, gint
3232
const gchar *flag_override);
3333

3434
gint get_line_number_rel(ScintillaObject *sci, gint shift);
35+
void ensure_current_line_expanded(ScintillaObject *sci);
3536

3637
#endif

0 commit comments

Comments
 (0)