aboutsummaryrefslogtreecommitdiff
path: root/src
diff options
context:
space:
mode:
authorzeertzjq <zeertzjq@outlook.com>2023-02-11 20:00:31 +0800
committerGitHub <noreply@github.com>2023-02-11 20:00:31 +0800
commit374955bcc571dff05f068ec18d0f578d1f334c5f (patch)
tree7abf6225aa4751316e1d6df16c3fcd3b4d311861 /src
parent414ff7742faad10f407f141534d5314acda0ec70 (diff)
downloadrneovim-374955bcc571dff05f068ec18d0f578d1f334c5f.tar.gz
rneovim-374955bcc571dff05f068ec18d0f578d1f334c5f.tar.bz2
rneovim-374955bcc571dff05f068ec18d0f578d1f334c5f.zip
vim-patch:9.0.1300: 'statusline' only supports one "%=" item (#22218)
Problem: 'statusline' only supports one "%=" item. Solution: Add support for multiple "%=" items. (TJ DeVries, Yegappan Lakshmanan, closes vim/vim#11970, closes vim/vim#11965) https://github.com/vim/vim/commit/3ec78f973fdaec2cea8e036ed38037b2fe40670b Co-authored-by: Yegappan Lakshmanan <yegappan@yahoo.com>
Diffstat (limited to 'src')
-rw-r--r--src/nvim/statusline.c13
-rw-r--r--src/nvim/testdir/test_statusline.vim4
2 files changed, 10 insertions, 7 deletions
diff --git a/src/nvim/statusline.c b/src/nvim/statusline.c
index a094a5f945..6e0dc2e8f7 100644
--- a/src/nvim/statusline.c
+++ b/src/nvim/statusline.c
@@ -1094,7 +1094,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n
continue;
}
- // STL_SEPARATE: Separation place between left and right aligned items.
+ // STL_SEPARATE: Separation between items, filled with white space.
if (*fmt_p == STL_SEPARATE) {
fmt_p++;
// Ignored when we are inside of a grouping
@@ -2066,8 +2066,7 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n
int num_separators = 0;
for (int i = 0; i < itemcnt; i++) {
if (stl_items[i].type == Separate) {
- // Create an array of the start location for each
- // separator mark.
+ // Create an array of the start location for each separator mark.
stl_separator_locations[num_separators] = i;
num_separators++;
}
@@ -2079,17 +2078,17 @@ int build_stl_str_hl(win_T *wp, char *out, size_t outlen, char *fmt, char *opt_n
int final_spaces = (maxwidth - width) -
standard_spaces * (num_separators - 1);
- for (int i = 0; i < num_separators; i++) {
- int dislocation = (i == (num_separators - 1)) ? final_spaces : standard_spaces;
+ for (int l = 0; l < num_separators; l++) {
+ int dislocation = (l == (num_separators - 1)) ? final_spaces : standard_spaces;
dislocation *= utf_char2len(fillchar);
- char *start = stl_items[stl_separator_locations[i]].start;
+ char *start = stl_items[stl_separator_locations[l]].start;
char *seploc = start + dislocation;
STRMOVE(seploc, start);
for (char *s = start; s < seploc;) {
MB_CHAR2BYTES(fillchar, s);
}
- for (int item_idx = stl_separator_locations[i] + 1;
+ for (int item_idx = stl_separator_locations[l] + 1;
item_idx < itemcnt;
item_idx++) {
stl_items[item_idx].start += dislocation;
diff --git a/src/nvim/testdir/test_statusline.vim b/src/nvim/testdir/test_statusline.vim
index 990c852ccd..1e06ad1c67 100644
--- a/src/nvim/testdir/test_statusline.vim
+++ b/src/nvim/testdir/test_statusline.vim
@@ -231,6 +231,10 @@ func Test_statusline()
" %=: Separation point between left and right aligned items.
set statusline=foo%=bar
call assert_match('^foo\s\+bar\s*$', s:get_statusline())
+ set statusline=foo%=bar%=baz
+ call assert_match('^foo\s\+bar\s\+baz\s*$', s:get_statusline())
+ set statusline=foo%=bar%=baz%=qux
+ call assert_match('^foo\s\+bar\s\+baz\s\+qux\s*$', s:get_statusline())
" Test min/max width, leading zeroes, left/right justify.
set statusline=%04B