This commit is contained in:
Jan Edmund Lazo
2019-05-26 21:45:46 -04:00
parent b2a11515b2
commit 3c3b7844b9
5 changed files with 35 additions and 40 deletions

View File

@@ -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)