diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-12-26 21:54:31 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-12-26 21:54:31 +0800 |
commit | 738427d4984f13ce5e7cda9cda2face9559ee7e7 (patch) | |
tree | 43c5b22693fbc81c86eda1be43a048f17a687869 /src/nvim/digraph.c | |
parent | 94ce25065bb709794904b8ee96c1144006520750 (diff) | |
download | rneovim-738427d4984f13ce5e7cda9cda2face9559ee7e7.tar.gz rneovim-738427d4984f13ce5e7cda9cda2face9559ee7e7.tar.bz2 rneovim-738427d4984f13ce5e7cda9cda2face9559ee7e7.zip |
vim-patch:9.0.1098: code uses too much indent (#21540)
Problem: Code uses too much indent.
Solution: Use an early return. (Yegappan Lakshmanan, closes vim/vim#11747)
https://github.com/vim/vim/commit/465de3a57b815f1188c707e7c083950c81652536
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/digraph.c')
-rw-r--r-- | src/nvim/digraph.c | 82 |
1 files changed, 42 insertions, 40 deletions
diff --git a/src/nvim/digraph.c b/src/nvim/digraph.c index 2ca608ad93..dc85b39684 100644 --- a/src/nvim/digraph.c +++ b/src/nvim/digraph.c @@ -1826,54 +1826,56 @@ static void printdigraph(const digr_T *dp, result_T *previous) char_u buf[30]; int list_width = 13; - if (dp->result != 0) { - if (previous != NULL) { - for (int i = 0; header_table[i].dg_header != NULL; i++) { - if (*previous < header_table[i].dg_start - && dp->result >= header_table[i].dg_start - && dp->result < header_table[i + 1].dg_start) { - digraph_header(_(header_table[i].dg_header)); - break; - } + if (dp->result == 0) { + return; + } + + if (previous != NULL) { + for (int i = 0; header_table[i].dg_header != NULL; i++) { + if (*previous < header_table[i].dg_start + && dp->result >= header_table[i].dg_start + && dp->result < header_table[i + 1].dg_start) { + digraph_header(_(header_table[i].dg_header)); + break; } - *previous = dp->result; - } - if (msg_col > Columns - list_width) { - msg_putchar('\n'); } + *previous = dp->result; + } + if (msg_col > Columns - list_width) { + msg_putchar('\n'); + } - // Make msg_col a multiple of list_width by using spaces. - if (msg_col % list_width != 0) { - int spaces = (msg_col / list_width + 1) * list_width - msg_col; - while (spaces--) { - msg_putchar(' '); - } + // Make msg_col a multiple of list_width by using spaces. + if (msg_col % list_width != 0) { + int spaces = (msg_col / list_width + 1) * list_width - msg_col; + while (spaces--) { + msg_putchar(' '); } + } - char_u *p = &buf[0]; - *p++ = dp->char1; - *p++ = dp->char2; - *p++ = ' '; - *p = NUL; - msg_outtrans((char *)buf); - p = buf; + char_u *p = &buf[0]; + *p++ = dp->char1; + *p++ = dp->char2; + *p++ = ' '; + *p = NUL; + msg_outtrans((char *)buf); + p = buf; - // add a space to draw a composing char on - if (utf_iscomposing(dp->result)) { - *p++ = ' '; - } - p += utf_char2bytes(dp->result, (char *)p); + // add a space to draw a composing char on + if (utf_iscomposing(dp->result)) { + *p++ = ' '; + } + p += utf_char2bytes(dp->result, (char *)p); - *p = NUL; - msg_outtrans_attr((char *)buf, HL_ATTR(HLF_8)); - p = buf; - if (char2cells(dp->result) == 1) { - *p++ = ' '; - } - assert(p >= buf); - vim_snprintf((char *)p, sizeof(buf) - (size_t)(p - buf), " %3d", dp->result); - msg_outtrans((char *)buf); + *p = NUL; + msg_outtrans_attr((char *)buf, HL_ATTR(HLF_8)); + p = buf; + if (char2cells(dp->result) == 1) { + *p++ = ' '; } + assert(p >= buf); + vim_snprintf((char *)p, sizeof(buf) - (size_t)(p - buf), " %3d", dp->result); + msg_outtrans((char *)buf); } /// Get the two digraph characters from a typval. |