refactor(drawline): reduce size of wlv.extra[] (#26733)

It's now only used for transchar_hex(), which only needs 11 bytes.
This commit is contained in:
zeertzjq 2023-12-25 18:57:55 +08:00 committed by GitHub
parent a42df11786
commit ddc8dd187d
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
2 changed files with 3 additions and 5 deletions

View File

@ -90,7 +90,7 @@ typedef struct {
bool extra_for_extmark; ///< n_extra set for inline virtual text
char extra[57]; ///< sign, line number and 'fdc' must fit in here
char extra[11]; ///< must be as large as transchar_charbuf[] in charset.c
hlf_T diff_hlf; ///< type of diff highlighting
@ -2329,9 +2329,7 @@ int win_line(win_T *wp, linenr_T lnum, int startrow, int endrow, bool number_onl
mb_c = (uint8_t)(*wlv.p_extra);
p = get_extra_buf((size_t)wlv.n_extra + 1);
memset(p, ' ', (size_t)wlv.n_extra);
strncpy(p, // NOLINT(runtime/printf)
wlv.p_extra + 1,
(size_t)strlen(wlv.p_extra) - 1);
memcpy(p, wlv.p_extra + 1, strlen(wlv.p_extra) - 1);
p[wlv.n_extra] = NUL;
wlv.p_extra = p;
} else {

View File

@ -1837,7 +1837,7 @@ describe('API/win_extmark', function()
-- notifications from 2nd call
{ {id = 1000}, ns, marks[1], 1, 0 },
{ {id = 1000}, ns, marks[2], 1, 2 },
-- notifications from 3nd call
-- notifications from 3rd call
{ {id = 1000}, ns, marks[1], 1, 0 },
{ {id = 1000}, ns, marks[2], 1, 2 },
{ {id = 1000}, ns, marks[3], 1, 4 },