diff options
author | dundargoc <gocdundar@gmail.com> | 2023-11-12 15:54:54 +0100 |
---|---|---|
committer | dundargoc <33953936+dundargoc@users.noreply.github.com> | 2023-11-13 23:39:56 +0100 |
commit | 28f4f3c48498086307ed825d1761edb5789ca0e8 (patch) | |
tree | 880d2104092261fe0457b17a9ddda8a6e0f7f2ed /src/nvim/help.c | |
parent | 48bcc7b9710d6db619b05254ea87f4087cdd9764 (diff) | |
download | rneovim-28f4f3c48498086307ed825d1761edb5789ca0e8.tar.gz rneovim-28f4f3c48498086307ed825d1761edb5789ca0e8.tar.bz2 rneovim-28f4f3c48498086307ed825d1761edb5789ca0e8.zip |
refactor: follow style guide
- reduce variable scope
- prefer initialization over declaration and assignment
- use bool to represent boolean values
Diffstat (limited to 'src/nvim/help.c')
-rw-r--r-- | src/nvim/help.c | 17 |
1 files changed, 6 insertions, 11 deletions
diff --git a/src/nvim/help.c b/src/nvim/help.c index 3e7577505d..14dc7b6623 100644 --- a/src/nvim/help.c +++ b/src/nvim/help.c @@ -55,8 +55,6 @@ void ex_help(exarg_T *eap) char **matches; int empty_fnum = 0; int alt_fnum = 0; - buf_T *buf; - int len; const bool old_KeyTyped = KeyTyped; if (eap != NULL) { @@ -105,7 +103,7 @@ void ex_help(exarg_T *eap) if (n != FAIL && lang != NULL) { // Find first item with the requested language. for (i = 0; i < num_matches; i++) { - len = (int)strlen(matches[i]); + int len = (int)strlen(matches[i]); if (len > 3 && matches[i][len - 3] == '@' && STRICMP(matches[i] + len - 2, lang) == 0) { break; @@ -196,7 +194,7 @@ void ex_help(exarg_T *eap) // may have jumped to another window, check that the buffer is not in a // window. if (empty_fnum != 0 && curbuf->b_fnum != empty_fnum) { - buf = buflist_findnr(empty_fnum); + buf_T *buf = buflist_findnr(empty_fnum); if (buf != NULL && buf->b_nwindows == 0) { wipe_buffer(buf, true); } @@ -647,9 +645,6 @@ void prepare_help_buffer(void) /// highlighting is not used. void fix_help_buffer(void) { - linenr_T lnum; - char *line; - // Set filetype to "help". if (strcmp(curbuf->b_p_ft, "help") != 0) { curbuf->b_ro_locked++; @@ -659,8 +654,8 @@ void fix_help_buffer(void) if (!syntax_present(curwin)) { bool in_example = false; - for (lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) { - line = ml_get_buf(curbuf, lnum); + for (linenr_T lnum = 1; lnum <= curbuf->b_ml.ml_line_count; lnum++) { + char *line = ml_get_buf(curbuf, lnum); const size_t len = strlen(line); if (in_example && len > 0 && !ascii_iswhite(line[0])) { // End of example: non-white or '<' in first column. @@ -695,8 +690,8 @@ void fix_help_buffer(void) && ASCII_ISALPHA(fname[6]) && TOLOWER_ASC(fname[7]) == 'x' && fname[8] == NUL)) { - for (lnum = 1; lnum < curbuf->b_ml.ml_line_count; lnum++) { - line = ml_get_buf(curbuf, lnum); + for (linenr_T lnum = 1; lnum < curbuf->b_ml.ml_line_count; lnum++) { + char *line = ml_get_buf(curbuf, lnum); if (strstr(line, "*local-additions*") == NULL) { continue; } |