diff options
-rw-r--r-- | src/nvim/eval.c | 3 | ||||
-rw-r--r-- | src/nvim/ex_docmd.c | 9 | ||||
-rw-r--r-- | src/nvim/getchar.c | 3 | ||||
-rw-r--r-- | src/nvim/normal.c | 47 | ||||
-rw-r--r-- | src/nvim/screen.c | 13 |
5 files changed, 35 insertions, 40 deletions
diff --git a/src/nvim/eval.c b/src/nvim/eval.c index aa4a3da9e5..deaed17926 100644 --- a/src/nvim/eval.c +++ b/src/nvim/eval.c @@ -13558,9 +13558,8 @@ static void f_readfile(typval_T *argvars, typval_T *rettv, FunPtr fptr) static void return_register(int regname, typval_T *rettv) { - char_u buf[2] = {0, 0}; + char_u buf[2] = { regname, 0 }; - buf[0] = (char_u)regname; rettv->v_type = VAR_STRING; rettv->vval.v_string = vim_strsave(buf); } diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index f55062af53..9e056d449b 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -1234,7 +1234,6 @@ static char_u * do_one_cmd(char_u **cmdlinep, int did_sandbox = FALSE; cmdmod_T save_cmdmod; const int save_reg_executing = reg_executing; - int ni; /* set when Not Implemented */ char_u *cmd; int address_count = 1; @@ -1763,10 +1762,10 @@ static char_u * do_one_cmd(char_u **cmdlinep, goto doend; } - ni = (!IS_USER_CMDIDX(ea.cmdidx) - && (cmdnames[ea.cmdidx].cmd_func == ex_ni - || cmdnames[ea.cmdidx].cmd_func == ex_script_ni - )); + // set when Not Implemented + const int ni = !IS_USER_CMDIDX(ea.cmdidx) + && (cmdnames[ea.cmdidx].cmd_func == ex_ni + || cmdnames[ea.cmdidx].cmd_func == ex_script_ni); // Forced commands. diff --git a/src/nvim/getchar.c b/src/nvim/getchar.c index 3e2cbf0a09..ef522242c6 100644 --- a/src/nvim/getchar.c +++ b/src/nvim/getchar.c @@ -1666,8 +1666,9 @@ static int vgetorpeek(int advance) init_typebuf(); start_stuff(); - if (advance && typebuf.tb_maplen == 0) + if (advance && typebuf.tb_maplen == 0) { reg_executing = 0; + } do { /* * get a character: 1. from the stuffbuffer diff --git a/src/nvim/normal.c b/src/nvim/normal.c index b63d3812d4..db2da6a807 100644 --- a/src/nvim/normal.c +++ b/src/nvim/normal.c @@ -541,30 +541,29 @@ static bool normal_need_additional_char(NormalState *s) int flags = nv_cmds[s->idx].cmd_flags; bool pending_op = s->oa.op_type != OP_NOP; int cmdchar = s->ca.cmdchar; - return - // without NV_NCH we never need to check for an additional char - flags & NV_NCH && ( - // NV_NCH_NOP is set and no operator is pending, get a second char - ((flags & NV_NCH_NOP) == NV_NCH_NOP && !pending_op) - // NV_NCH_ALW is set, always get a second char - || (flags & NV_NCH_ALW) == NV_NCH_ALW - // 'q' without a pending operator, recording or executing a register, - // needs to be followed by a second char, examples: - // - qc => record using register c - // - q: => open command-line window - || (cmdchar == 'q' - && !pending_op - && reg_recording == 0 - && reg_executing == 0) - // 'a' or 'i' after an operator is a text object, examples: - // - ciw => change inside word - // - da( => delete parenthesis and everything inside. - // Also, don't do anything when these keys are received in visual mode - // so just get another char. - // - // TODO(tarruda): Visual state needs to be refactored into a - // separate state that "inherits" from normal state. - || ((cmdchar == 'a' || cmdchar == 'i') && (pending_op || VIsual_active))); + // without NV_NCH we never need to check for an additional char + return flags & NV_NCH && ( + // NV_NCH_NOP is set and no operator is pending, get a second char + ((flags & NV_NCH_NOP) == NV_NCH_NOP && !pending_op) + // NV_NCH_ALW is set, always get a second char + || (flags & NV_NCH_ALW) == NV_NCH_ALW + // 'q' without a pending operator, recording or executing a register, + // needs to be followed by a second char, examples: + // - qc => record using register c + // - q: => open command-line window + || (cmdchar == 'q' + && !pending_op + && reg_recording == 0 + && reg_executing == 0) + // 'a' or 'i' after an operator is a text object, examples: + // - ciw => change inside word + // - da( => delete parenthesis and everything inside. + // Also, don't do anything when these keys are received in visual mode + // so just get another char. + // + // TODO(tarruda): Visual state needs to be refactored into a + // separate state that "inherits" from normal state. + || ((cmdchar == 'a' || cmdchar == 'i') && (pending_op || VIsual_active))); } static bool normal_need_redraw_mode_message(NormalState *s) diff --git a/src/nvim/screen.c b/src/nvim/screen.c index e5e4a850df..fe9fba7af6 100644 --- a/src/nvim/screen.c +++ b/src/nvim/screen.c @@ -6410,14 +6410,11 @@ int showmode(void) && ((State & TERM_FOCUS) || (State & INSERT) || restart_edit - || VIsual_active - )); + || VIsual_active)); if (do_mode || reg_recording != 0) { - /* - * Don't show mode right now, when not redrawing or inside a mapping. - * Call char_avail() only when we are going to show something, because - * it takes a bit of time. - */ + // Don't show mode right now, when not redrawing or inside a mapping. + // Call char_avail() only when we are going to show something, because + // it takes a bit of time. if (!redrawing() || (char_avail() && !KeyTyped) || msg_silent != 0) { redraw_cmdline = TRUE; /* show mode later */ return 0; @@ -6534,7 +6531,7 @@ int showmode(void) need_clear = TRUE; } if (reg_recording != 0 - && edit_submode == NULL /* otherwise it gets too long */ + && edit_submode == NULL // otherwise it gets too long ) { recording_mode(attr); need_clear = true; |