diff options
author | zeertzjq <zeertzjq@outlook.com> | 2023-06-30 08:36:09 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2023-06-30 08:36:09 +0800 |
commit | d7bb19e0138c7363ed40c142972c07e4e1912785 (patch) | |
tree | 5fe1e81723319cc4b8a6bc88a42fc2c69ae68f17 /src | |
parent | 8758c6fb875ff5446c0dff2166e9c3392c2c31d6 (diff) | |
download | rneovim-d7bb19e0138c7363ed40c142972c07e4e1912785.tar.gz rneovim-d7bb19e0138c7363ed40c142972c07e4e1912785.tar.bz2 rneovim-d7bb19e0138c7363ed40c142972c07e4e1912785.zip |
fix(statusline): fill for double-width char after moving items (#24207)
Diffstat (limited to 'src')
-rw-r--r-- | src/nvim/statusline.c | 23 |
1 files changed, 12 insertions, 11 deletions
diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c index dd602ddf87..f2502fe1e3 100644 --- a/src/nvim/statusline.c +++ b/src/nvim/statusline.c @@ -263,6 +263,7 @@ void stl_fill_click_defs(StlClickDefinition *click_defs, StlClickRecord *click_r }; for (int i = 0; click_recs[i].start != NULL; i++) { len += vim_strnsize(buf, (int)(click_recs[i].start - buf)); + assert(len <= width); if (col < len) { while (col < len) { click_defs[col++] = cur_click_def; @@ -2052,17 +2053,6 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n // Put a `<` to mark where we truncated at *trunc_p = '<'; - - if (width + 1 < maxwidth) { - // Advance the pointer to the end of the string - trunc_p = trunc_p + strlen(trunc_p); - } - - // Fill up for half a double-wide character. - while (++width < maxwidth) { - MB_CHAR2BYTES(fillchar, trunc_p); - *trunc_p = NUL; - } // } // { Change the start point for items based on @@ -2084,6 +2074,17 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n } } // } + + if (width + 1 < maxwidth) { + // Advance the pointer to the end of the string + trunc_p = trunc_p + strlen(trunc_p); + } + + // Fill up for half a double-wide character. + while (++width < maxwidth) { + MB_CHAR2BYTES(fillchar, trunc_p); + *trunc_p = NUL; + } } width = maxwidth; |