diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-01-26 08:52:21 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-01-26 08:52:21 +0800 |
commit | 88e906d165b5dd57fb13b190ec9cb2d67bc6b223 (patch) | |
tree | 94dfb6c6b095db1c695c7909c62fc47c8f0b0b38 /src/nvim/textformat.c | |
parent | f15947866ce59589346a4074a1fdc10f941a16b5 (diff) | |
download | rneovim-88e906d165b5dd57fb13b190ec9cb2d67bc6b223.tar.gz rneovim-88e906d165b5dd57fb13b190ec9cb2d67bc6b223.tar.bz2 rneovim-88e906d165b5dd57fb13b190ec9cb2d67bc6b223.zip |
vim-patch:9.0.1245: code is indented more than necessary (#21998)
Problem: Code is indented more than necessary.
Solution: Use an early return where it makes sense. (Yegappan Lakshmanan,
closes vim/vim#11879)
https://github.com/vim/vim/commit/032713f8299abd92fcfb1e490d1ae5c1ecadde41
Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src/nvim/textformat.c')
-rw-r--r-- | src/nvim/textformat.c | 32 |
1 files changed, 17 insertions, 15 deletions
diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c index fbea1ccfb7..e30580a748 100644 --- a/src/nvim/textformat.c +++ b/src/nvim/textformat.c @@ -736,22 +736,24 @@ void check_auto_format(bool end_insert) int c = ' '; int cc; - if (did_add_space) { - cc = gchar_cursor(); - if (!WHITECHAR(cc)) { - // Somehow the space was removed already. + if (!did_add_space) { + return; + } + + cc = gchar_cursor(); + if (!WHITECHAR(cc)) { + // Somehow the space was removed already. + did_add_space = false; + } else { + if (!end_insert) { + inc_cursor(); + c = gchar_cursor(); + dec_cursor(); + } + if (c != NUL) { + // The space is no longer at the end of the line, delete it. + del_char(false); did_add_space = false; - } else { - if (!end_insert) { - inc_cursor(); - c = gchar_cursor(); - dec_cursor(); - } - if (c != NUL) { - // The space is no longer at the end of the line, delete it. - del_char(false); - did_add_space = false; - } } } } |