]> granicus.if.org Git - vim/commitdiff
patch 8.1.0416: sort doesn't report deleted lines v8.1.0416
authorBram Moolenaar <Bram@vim.org>
Fri, 21 Sep 2018 10:46:22 +0000 (12:46 +0200)
committerBram Moolenaar <Bram@vim.org>
Fri, 21 Sep 2018 10:46:22 +0000 (12:46 +0200)
Problem:    Sort doesn't report deleted lines.
Solution:   Call msgmore(). (Christian Brabandt, closes #3454)

src/ex_cmds.c
src/testdir/test_sort.vim
src/version.c

index 0a87f7b38fcc9d3ef86a0d828227faa5c73a69bf..0c9644cc646a4ac1155d00f9bbad6f5d1148fd8f 100644 (file)
@@ -649,7 +649,10 @@ ex_sort(exarg_T *eap)
     /* Adjust marks for deleted (or added) lines and prepare for displaying. */
     deleted = (long)(count - (lnum - eap->line2));
     if (deleted > 0)
+    {
        mark_adjust(eap->line2 - deleted, eap->line2, (long)MAXLNUM, -deleted);
+       msgmore(-deleted);
+    }
     else if (deleted < 0)
        mark_adjust(eap->line2, MAXLNUM, -deleted, 0L);
 
index 6dc1d468c0ef5822e4c4d55f90aeeb79c9c68d1e..14d008a17f56fa6532cfc70a22c1654bdbfbbebd 100644 (file)
@@ -1221,3 +1221,33 @@ func Test_sort_cmd()
 
   enew!
 endfunc
+
+func Test_sort_cmd_report()
+    enew!
+    call append(0, repeat([1], 3) + repeat([2], 3) + repeat([3], 3))
+    $delete _
+    setlocal nomodified
+    let res = execute('%sort u')
+
+    call assert_equal([1,2,3], map(getline(1, '$'), 'v:val+0'))
+    call assert_match("6 fewer lines", res)
+    enew!
+    call append(0, repeat([1], 3) + repeat([2], 3) + repeat([3], 3))
+    $delete _
+    setlocal nomodified report=10
+    let res = execute('%sort u')
+
+    call assert_equal([1,2,3], map(getline(1, '$'), 'v:val+0'))
+    call assert_equal("", res)
+    enew!
+    call append(0, repeat([1], 3) + repeat([2], 3) + repeat([3], 3))
+    $delete _
+    setl report&vim
+    setlocal nomodified
+    let res = execute('1g/^/%sort u')
+
+    call assert_equal([1,2,3], map(getline(1, '$'), 'v:val+0'))
+    " the output comes from the :g command, not from the :sort
+    call assert_match("6 fewer lines", res)
+    enew!
+  endfunc
index 637ea9909fec08016087838053dfe4458dffe876..b76df9eea330f203eed4a6d917c4efaecbb3fb04 100644 (file)
@@ -794,6 +794,8 @@ static char *(features[]) =
 
 static int included_patches[] =
 {   /* Add new patch number below this line */
+/**/
+    416,
 /**/
     415,
 /**/