mirror of
https://github.com/neovim/neovim.git
synced 2025-10-13 05:16:09 +00:00
Add Boolean argument escape_csi to vim_feedkeys
- By default vim_feedkeys escaped all input for CSI/K_SPECIAL bytes before using it. However since vim_replace_termcodes() also escapes the input string chaining these functions together escapes input twice - vim_feedkeys() now takes a third Boolean argument to enable/disable escaping - Breaks API compatibility
This commit is contained in:

committed by
Thiago de Arruda

parent
a6b7b92431
commit
e644369f6e
@@ -49,8 +49,10 @@ void vim_command(String str, Error *err)
|
||||
///
|
||||
/// @param keys to be typed
|
||||
/// @param mode specifies the mapping options
|
||||
/// @param escape_csi the string needs escaping for K_SPECIAL/CSI bytes
|
||||
/// @see feedkeys()
|
||||
void vim_feedkeys(String keys, String mode)
|
||||
/// @see vim_strsave_escape_csi
|
||||
void vim_feedkeys(String keys, String mode, Boolean escape_csi)
|
||||
FUNC_ATTR_DEFERRED
|
||||
{
|
||||
bool remap = true;
|
||||
@@ -68,12 +70,20 @@ void vim_feedkeys(String keys, String mode)
|
||||
}
|
||||
}
|
||||
|
||||
/* Need to escape K_SPECIAL and CSI before putting the string in the
|
||||
* typeahead buffer. */
|
||||
char *keys_esc = (char *)vim_strsave_escape_csi((char_u *)keys.data);
|
||||
char *keys_esc;
|
||||
if (escape_csi) {
|
||||
// Need to escape K_SPECIAL and CSI before putting the string in the
|
||||
// typeahead buffer.
|
||||
keys_esc = (char *)vim_strsave_escape_csi((char_u *)keys.data);
|
||||
} else {
|
||||
keys_esc = keys.data;
|
||||
}
|
||||
ins_typebuf((char_u *)keys_esc, (remap ? REMAP_YES : REMAP_NONE),
|
||||
typebuf.tb_len, !typed, false);
|
||||
free(keys_esc);
|
||||
|
||||
if (escape_csi) {
|
||||
free(keys_esc);
|
||||
}
|
||||
|
||||
if (vgetc_busy)
|
||||
typebuf_was_filled = true;
|
||||
|
@@ -8414,7 +8414,7 @@ static void f_feedkeys(typval_T *argvars, typval_T *rettv)
|
||||
}
|
||||
|
||||
vim_feedkeys(cstr_as_string((char *)keys),
|
||||
cstr_as_string((char *)flags));
|
||||
cstr_as_string((char *)flags), true);
|
||||
}
|
||||
}
|
||||
|
||||
|
Reference in New Issue
Block a user