refactor: follow style guide

- reduce variable scope
- prefer initialization over declaration and assignment
This commit is contained in:
dundargoc
2023-11-13 23:40:37 +01:00
committed by dundargoc
parent 1798a4b5e9
commit ac1113ded5
52 changed files with 713 additions and 1269 deletions

View File

@@ -420,10 +420,7 @@ void pum_redraw(void)
int row = 0;
int attr_scroll = win_hl_attr(curwin, HLF_PSB);
int attr_thumb = win_hl_attr(curwin, HLF_PST);
char *s;
char *p = NULL;
int width;
int w;
int thumb_pos = 0;
int thumb_height = 1;
int n;
@@ -524,8 +521,8 @@ void pum_redraw(void)
for (int round = 0; round < 3; round++) {
attr = attrs[round];
width = 0;
s = NULL;
int width = 0;
char *s = NULL;
switch (round) {
case 0:
@@ -541,7 +538,7 @@ void pum_redraw(void)
if (s == NULL) {
s = p;
}
w = ptr2cells(p);
int w = ptr2cells(p);
if ((*p == NUL) || (*p == TAB) || (totwidth + w > pum_width)) {
// Display the text that fits or comes before a Tab.
@@ -778,11 +775,10 @@ static bool pum_set_selected(int n, int repeat)
}
if (res == OK) {
char *p, *e;
linenr_T lnum = 0;
for (p = pum_array[pum_selected].pum_info; *p != NUL;) {
e = vim_strchr(p, '\n');
for (char *p = pum_array[pum_selected].pum_info; *p != NUL;) {
char *e = vim_strchr(p, '\n');
if (e == NULL) {
ml_append(lnum++, p, 0, false);
break;