diff options
| author | dundargoc <gocdundar@gmail.com> | 2022-10-22 12:36:38 +0200 |
|---|---|---|
| committer | dundargoc <gocdundar@gmail.com> | 2022-11-06 11:44:10 +0100 |
| commit | 731cdde28ea8d48cc23ba2752a08c261c87eee92 (patch) | |
| tree | 92e814050fdbca64aca435f03975b6d5678fbdf3 /src/nvim/tui | |
| parent | a79d28e4d7939c13f38cf4ce63ff240011bca96d (diff) | |
| download | rneovim-731cdde28ea8d48cc23ba2752a08c261c87eee92.tar.gz rneovim-731cdde28ea8d48cc23ba2752a08c261c87eee92.tar.bz2 rneovim-731cdde28ea8d48cc23ba2752a08c261c87eee92.zip | |
refactor: fix clang-tidy warnings
Enable and fix bugprone-misplaced-widening-cast warning.
Fix some modernize-macro-to-enum and readability-else-after-return
warnings, but don't enable them. While the warnings can be useful, they
are in general too noisy to enable.
Diffstat (limited to 'src/nvim/tui')
| -rw-r--r-- | src/nvim/tui/input.c | 44 | ||||
| -rw-r--r-- | src/nvim/tui/tui.c | 3 |
2 files changed, 22 insertions, 25 deletions
diff --git a/src/nvim/tui/input.c b/src/nvim/tui/input.c index fbeca26274..2089686e5e 100644 --- a/src/nvim/tui/input.c +++ b/src/nvim/tui/input.c @@ -324,15 +324,14 @@ static void forward_simple_utf8(TermInput *input, TermKeyKey *key) && map_has(KittyKey, cstr_t)(&kitty_key_map, (KittyKey)key->code.codepoint)) { handle_kitty_key_protocol(input, key); return; - } else { - while (*ptr) { - if (*ptr == '<') { - len += (size_t)snprintf(buf + len, sizeof(buf) - len, "<lt>"); - } else { - buf[len++] = *ptr; - } - ptr++; + } + while (*ptr) { + if (*ptr == '<') { + len += (size_t)snprintf(buf + len, sizeof(buf) - len, "<lt>"); + } else { + buf[len++] = *ptr; } + ptr++; } tinput_enqueue(input, buf, len); @@ -355,21 +354,20 @@ static void forward_modified_utf8(TermInput *input, TermKeyKey *key) (KittyKey)key->code.codepoint)) { handle_kitty_key_protocol(input, key); return; - } else { - // Termkey doesn't include the S- modifier for ASCII characters (e.g., - // ctrl-shift-l is <C-L> instead of <C-S-L>. Vim, on the other hand, - // treats <C-L> and <C-l> the same, requiring the S- modifier. - len = termkey_strfkey(input->tk, buf, sizeof(buf), key, TERMKEY_FORMAT_VIM); - if ((key->modifiers & TERMKEY_KEYMOD_CTRL) - && !(key->modifiers & TERMKEY_KEYMOD_SHIFT) - && ASCII_ISUPPER(key->code.codepoint)) { - assert(len <= 62); - // Make room for the S- - memmove(buf + 3, buf + 1, len - 1); - buf[1] = 'S'; - buf[2] = '-'; - len += 2; - } + } + // Termkey doesn't include the S- modifier for ASCII characters (e.g., + // ctrl-shift-l is <C-L> instead of <C-S-L>. Vim, on the other hand, + // treats <C-L> and <C-l> the same, requiring the S- modifier. + len = termkey_strfkey(input->tk, buf, sizeof(buf), key, TERMKEY_FORMAT_VIM); + if ((key->modifiers & TERMKEY_KEYMOD_CTRL) + && !(key->modifiers & TERMKEY_KEYMOD_SHIFT) + && ASCII_ISUPPER(key->code.codepoint)) { + assert(len <= 62); + // Make room for the S- + memmove(buf + 3, buf + 1, len - 1); + buf[1] = 'S'; + buf[2] = '-'; + len += 2; } } diff --git a/src/nvim/tui/tui.c b/src/nvim/tui/tui.c index 083677a58e..e2d37860c4 100644 --- a/src/nvim/tui/tui.c +++ b/src/nvim/tui/tui.c @@ -1651,9 +1651,8 @@ static void out(void *ctx, const char *str, size_t len) // Called by unibi_format(): avoid flush_buf() halfway an escape sequence. data->overflow = true; return; - } else { - flush_buf(ui); } + flush_buf(ui); } memcpy(data->buf + data->bufpos, str, len); |