mirror of
https://github.com/neovim/neovim.git
synced 2025-09-28 05:58:33 +00:00
vim-patch:partial:9.0.1196: code is indented more than necessary (#21796)
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes vim/vim#11813)
e857598896
Partial port as this depends on some previous eval and 'smoothscroll'
patches.
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
This commit is contained in:
@@ -403,22 +403,24 @@ int name_to_mod_mask(int c)
|
||||
int simplify_key(const int key, int *modifiers)
|
||||
FUNC_ATTR_WARN_UNUSED_RESULT FUNC_ATTR_NONNULL_ALL
|
||||
{
|
||||
if (*modifiers & (MOD_MASK_SHIFT | MOD_MASK_CTRL | MOD_MASK_ALT)) {
|
||||
// TAB is a special case.
|
||||
if (key == TAB && (*modifiers & MOD_MASK_SHIFT)) {
|
||||
*modifiers &= ~MOD_MASK_SHIFT;
|
||||
return K_S_TAB;
|
||||
}
|
||||
const int key0 = KEY2TERMCAP0(key);
|
||||
const int key1 = KEY2TERMCAP1(key);
|
||||
for (int i = 0; modifier_keys_table[i] != NUL; i += MOD_KEYS_ENTRY_SIZE) {
|
||||
if (key0 == modifier_keys_table[i + 3]
|
||||
&& key1 == modifier_keys_table[i + 4]
|
||||
&& (*modifiers & modifier_keys_table[i])) {
|
||||
*modifiers &= ~modifier_keys_table[i];
|
||||
return TERMCAP2KEY(modifier_keys_table[i + 1],
|
||||
modifier_keys_table[i + 2]);
|
||||
}
|
||||
if (!(*modifiers & (MOD_MASK_SHIFT | MOD_MASK_CTRL | MOD_MASK_ALT))) {
|
||||
return key;
|
||||
}
|
||||
|
||||
// TAB is a special case.
|
||||
if (key == TAB && (*modifiers & MOD_MASK_SHIFT)) {
|
||||
*modifiers &= ~MOD_MASK_SHIFT;
|
||||
return K_S_TAB;
|
||||
}
|
||||
const int key0 = KEY2TERMCAP0(key);
|
||||
const int key1 = KEY2TERMCAP1(key);
|
||||
for (int i = 0; modifier_keys_table[i] != NUL; i += MOD_KEYS_ENTRY_SIZE) {
|
||||
if (key0 == modifier_keys_table[i + 3]
|
||||
&& key1 == modifier_keys_table[i + 4]
|
||||
&& (*modifiers & modifier_keys_table[i])) {
|
||||
*modifiers &= ~modifier_keys_table[i];
|
||||
return TERMCAP2KEY(modifier_keys_table[i + 1],
|
||||
modifier_keys_table[i + 2]);
|
||||
}
|
||||
}
|
||||
return key;
|
||||
|
Reference in New Issue
Block a user