From: Daniel Carl Date: Wed, 3 Dec 2014 20:43:44 +0000 (+0100) Subject: Avoid input clear in case autocmd is run. X-Git-Url: https://git.owens.tech///git?a=commitdiff_plain;h=ab5dd2bac0cfd72b7b23cee8411352fef46929fa;p=vimb.git Avoid input clear in case autocmd is run. If a page is opened and the user types the next ex command into inputbox, this was removed in case there where autocmd triggered. The autocmd started ex commands that cause the clearing of the inputbox. --- diff --git a/src/ex.c b/src/ex.c index fb5f136..6964f6d 100644 --- a/src/ex.c +++ b/src/ex.c @@ -441,6 +441,7 @@ static void input_activate(void) { int count = -1; char *text, *cmd; + VbCmdResult res; text = vb_get_input_text(); /* skip leading prompt char like ':' or '/' */ @@ -459,14 +460,18 @@ static void input_activate(void) case ':': mode_enter('n'); - ex_run_string(cmd); + res = ex_run_string(cmd); + if (!(res & VB_CMD_KEEPINPUT)) { + /* clear input on success if this is not explicit ommited */ + vb_set_input_text(""); + } break; } g_free(text); } -gboolean ex_run_string(const char *input) +VbCmdResult ex_run_string(const char *input) { VbCmdResult res = VB_CMD_ERROR; ExArg *arg = g_slice_new0(ExArg); @@ -479,17 +484,12 @@ gboolean ex_run_string(const char *input) while (input && *input) { if (!parse(&input, arg) || !(res = execute(arg))) { free_cmdarg(arg); - return false; + return VB_CMD_ERROR; } } - /* check the result of the last executed command */ - if (!(res & VB_CMD_KEEPINPUT)) { - /* clear input text on success if this is not explicit ommited */ - vb_set_input_text(""); - } free_cmdarg(arg); - return true; + return res; } /** diff --git a/src/ex.h b/src/ex.h index b8901fc..f77a660 100644 --- a/src/ex.h +++ b/src/ex.h @@ -28,6 +28,6 @@ void ex_leave(void); VbResult ex_keypress(int key); void ex_input_changed(const char *text); gboolean ex_fill_completion(GtkListStore *store, const char *input); -gboolean ex_run_string(const char *input); +VbCmdResult ex_run_string(const char *input); #endif /* end of include guard: _EX_H */ diff --git a/src/main.c b/src/main.c index fe4f24b..ad3ccbb 100644 --- a/src/main.c +++ b/src/main.c @@ -917,7 +917,7 @@ static void read_config(void) if (*line == '#') { continue; } - if (!ex_run_string(line)) { + if (ex_run_string(line) & VB_CMD_ERROR ) { g_warning("Invalid user config: '%s'", line); } }