]> git.ipfire.org Git - thirdparty/vim.git/commitdiff
patch 9.0.1461: ruler not drawn correctly when using 'rulerformat' v9.0.1461
authorSean Dewar <seandewar@users.noreply.github.com>
Mon, 17 Apr 2023 15:41:20 +0000 (16:41 +0100)
committerBram Moolenaar <Bram@vim.org>
Mon, 17 Apr 2023 15:41:20 +0000 (16:41 +0100)
Problem:    Ruler not drawn correctly when using 'rulerformat'.
Solution:   Adjust formatting depending on whether the ruler is drawn in the
            statusline or the command line. (Sean Dewar, closes #12246)

src/screen.c
src/testdir/dumps/Test_rulerformat_position.dump [new file with mode: 0644]
src/testdir/test_cmdline.vim
src/version.c

index 6d48ad71220bddf0af13f3284c6124de1e02e55a..cbf2ab3d8430b786890b3b286d703aa16f1318f6 100644 (file)
@@ -1043,7 +1043,8 @@ win_redr_custom(
     {
        row = statusline_row(wp);
        fillchar = fillchar_status(&attr, wp);
-       maxwidth = wp->w_width;
+       int in_status_line = wp->w_status_height != 0;
+       maxwidth = in_status_line ? wp->w_width : Columns;
 
        if (draw_ruler)
        {
@@ -1060,11 +1061,11 @@ win_redr_custom(
                if (*stl++ != '(')
                    stl = p_ruf;
            }
-           col = ru_col - (Columns - wp->w_width);
-           if (col < (wp->w_width + 1) / 2)
-               col = (wp->w_width + 1) / 2;
-           maxwidth = wp->w_width - col;
-           if (!wp->w_status_height)
+           col = ru_col - (Columns - maxwidth);
+           if (col < (maxwidth + 1) / 2)
+               col = (maxwidth + 1) / 2;
+           maxwidth -= col;
+           if (!in_status_line)
            {
                row = Rows - 1;
                --maxwidth;     // writing in last column may cause scrolling
@@ -1084,7 +1085,8 @@ win_redr_custom(
                stl = p_stl;
        }
 
-       col += wp->w_wincol;
+       if (in_status_line)
+           col += wp->w_wincol;
     }
 
     if (maxwidth <= 0)
diff --git a/src/testdir/dumps/Test_rulerformat_position.dump b/src/testdir/dumps/Test_rulerformat_position.dump
new file mode 100644 (file)
index 0000000..2787a92
--- /dev/null
@@ -0,0 +1,2 @@
+| +0&#ffffff0@17||+1&&> +0&&
+@10|l|o|n|g|i|s|h| @2
index 8b717b7c2df462b63b484b06cfc7b30b72d01d46..9bb21bcfa9ba1d969c31e0c886a86b764d35cb94 100644 (file)
@@ -3459,4 +3459,17 @@ func Test_setcmdline()
   cunmap a
 endfunc
 
+func Test_rulerformat_position()
+  CheckScreendump
+
+  let buf = RunVimInTerminal('', #{rows: 2, cols: 20})
+  call term_sendkeys(buf, ":set ruler rulerformat=longish\<CR>")
+  call term_sendkeys(buf, ":set laststatus=0 winwidth=1\<CR>")
+  call term_sendkeys(buf, "\<C-W>v\<C-W>|\<C-W>p")
+  call VerifyScreenDump(buf, 'Test_rulerformat_position', {})
+
+  " clean up
+  call StopVimInTerminal(buf)
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab
index 4f54fab42efb3e6a9fb98dcbed0243d3c4bcca75..053fe7827897608b4f51110a45de54645e85447a 100644 (file)
@@ -695,6 +695,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    1461,
 /**/
     1460,
 /**/