Branch: refs/heads/master Author: Jiří Techet techet@gmail.com Committer: Jiří Techet techet@gmail.com Date: Tue, 21 May 2024 21:45:11 UTC Commit: 33984abc9bd24bbf03db3ac517eb45ca2c7e6b7f https://github.com/geany/geany-plugins/commit/33984abc9bd24bbf03db3ac517eb45...
Log Message: ----------- 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.
Modified Paths: -------------- vimode/src/cmd-runner.c vimode/src/excmd-runner.c vimode/src/utils.c vimode/src/utils.h
Modified: vimode/src/cmd-runner.c 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -704,6 +704,7 @@ static gboolean process_cmd(CmdDef *cmds, CmdContext *ctx, gboolean ins_mode) { if (orig_mode == VI_MODE_COMMAND_SINGLE) vi_set_mode(VI_MODE_INSERT); + ensure_current_line_expanded(ctx->sci); } else if (!consumed && ctx->kpl) {
Modified: vimode/src/excmd-runner.c 2 lines changed, 2 insertions(+), 0 deletions(-) =================================================================== @@ -465,6 +465,7 @@ void excmd_perform(CmdContext *ctx, const gchar *cmd) { case ':': perform_simple_ex_cmd(ctx, cmd + 1); + ensure_current_line_expanded(ctx->sci); break; case '/': case '?': @@ -483,6 +484,7 @@ void excmd_perform(CmdContext *ctx, const gchar *cmd) pos = perform_search(ctx->sci, ctx->search_text, ctx->num, FALSE); if (pos >= 0) SET_POS(ctx->sci, pos, TRUE); + ensure_current_line_expanded(ctx->sci); break; } }
Modified: vimode/src/utils.c 8 lines changed, 8 insertions(+), 0 deletions(-) =================================================================== @@ -219,3 +219,11 @@ void goto_nonempty(ScintillaObject *sci, gint line, gboolean scroll) pos = NEXT(sci, pos); SET_POS(sci, pos, scroll); } + + +void ensure_current_line_expanded(ScintillaObject *sci) +{ + gint line = GET_CUR_LINE(sci); + if (!SSM(sci, SCI_GETLINEVISIBLE, line, 0)) + SSM(sci, SCI_ENSUREVISIBLE, line, 0); +}
Modified: vimode/src/utils.h 1 lines changed, 1 insertions(+), 0 deletions(-) =================================================================== @@ -32,5 +32,6 @@ void perform_substitute(ScintillaObject *sci, const gchar *cmd, gint from, gint const gchar *flag_override);
gint get_line_number_rel(ScintillaObject *sci, gint shift); +void ensure_current_line_expanded(ScintillaObject *sci);
#endif
-------------- This E-Mail was brought to you by github_commit_mail.py (Source: https://github.com/geany/infrastructure).
plugins-commits@lists.geany.org