diff options
author | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2023-02-12 18:48:49 +0100 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-02-12 18:48:49 +0100 |
commit | 5f72ab77bff1f1224be5cbbf9423bdddbc25635c (patch) | |
tree | 433c1cd4aca0b8d8b91a8b219327940957993bdb /src/nvim/textformat.c | |
parent | 2b1c07a1d435b541c295afad13227ebb10def57e (diff) | |
download | rneovim-5f72ab77bff1f1224be5cbbf9423bdddbc25635c.tar.gz rneovim-5f72ab77bff1f1224be5cbbf9423bdddbc25635c.tar.bz2 rneovim-5f72ab77bff1f1224be5cbbf9423bdddbc25635c.zip |
refactor: reduce scope of locals as per the style guide 3 (#22221)
refactor: reduce scope of locals as per the style guide
Diffstat (limited to 'src/nvim/textformat.c')
-rw-r--r-- | src/nvim/textformat.c | 18 |
1 files changed, 6 insertions, 12 deletions
diff --git a/src/nvim/textformat.c b/src/nvim/textformat.c index 69cc0e046b..05e57e4b8f 100644 --- a/src/nvim/textformat.c +++ b/src/nvim/textformat.c @@ -633,19 +633,16 @@ static bool paragraph_start(linenr_T lnum) /// @param prev_line may start in previous line void auto_format(bool trailblank, bool prev_line) { - pos_T pos; colnr_T len; - char *old; char *new, *pnew; - int wasatend; int cc; if (!has_format_option(FO_AUTO)) { return; } - pos = curwin->w_cursor; - old = get_cursor_line_ptr(); + pos_T pos = curwin->w_cursor; + char *old = get_cursor_line_ptr(); // may remove added space check_auto_format(false); @@ -655,7 +652,7 @@ void auto_format(bool trailblank, bool prev_line) // in 'formatoptions' and there is a single character before the cursor. // Otherwise the line would be broken and when typing another non-white // next they are not joined back together. - wasatend = (pos.col == (colnr_T)strlen(old)); + int wasatend = (pos.col == (colnr_T)strlen(old)); if (*old != NUL && !trailblank && wasatend) { dec_cursor(); cc = gchar_cursor(); @@ -733,18 +730,16 @@ void auto_format(bool trailblank, bool prev_line) /// @param end_insert true when ending Insert mode void check_auto_format(bool end_insert) { - int c = ' '; - int cc; - if (!did_add_space) { return; } - cc = gchar_cursor(); + int cc = gchar_cursor(); if (!WHITECHAR(cc)) { // Somehow the space was removed already. did_add_space = false; } else { + int c = ' '; if (!end_insert) { inc_cursor(); c = gchar_cursor(); @@ -886,7 +881,6 @@ void op_formatexpr(oparg_T *oap) int fex_format(linenr_T lnum, long count, int c) { int use_sandbox = was_set_insecurely(curwin, "formatexpr", OPT_LOCAL); - int r; // Set v:lnum to the first line number and v:count to the number of lines. // Set v:char to the character to be inserted (can be NUL). @@ -900,7 +894,7 @@ int fex_format(linenr_T lnum, long count, int c) if (use_sandbox) { sandbox++; } - r = (int)eval_to_number(fex); + int r = (int)eval_to_number(fex); if (use_sandbox) { sandbox--; } |