diff src/testdir/test_fold.vim @ 31047:ac1f548223a5 v9.0.0858

patch 9.0.0858: "!!sort" in a closed fold sorts too many lines Commit: https://github.com/vim/vim/commit/f00112d558eb9a7d1d5413c096960ddcc52c9f66 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Nov 11 01:20:35 2022 +0000 patch 9.0.0858: "!!sort" in a closed fold sorts too many lines Problem: "!!sort" in a closed fold sorts too many lines. Solution: Round to end of fold after adding the line count. (closes https://github.com/vim/vim/issues/11487)
author Bram Moolenaar <Bram@vim.org>
date Fri, 11 Nov 2022 02:30:03 +0100
parents 360f286b5869
children 39f96b1e7b8d
line wrap: on
line diff
--- a/src/testdir/test_fold.vim
+++ b/src/testdir/test_fold.vim
@@ -1570,4 +1570,40 @@ func Test_indent_append_blank_small_fold
   bw!
 endfunc
 
+func Test_sort_closed_fold()
+  CheckExecutable sort
+
+  call setline(1, [
+        \ 'Section 1',
+        \ '   how',
+        \ '   now',
+        \ '   brown',
+        \ '   cow',
+        \ 'Section 2',
+        \ '   how',
+        \ '   now',
+        \ '   brown',
+        \ '   cow',
+        \])
+  setlocal foldmethod=indent sw=3
+  normal 2G
+
+  " The "!!" expands to ".,.+3" and must only sort four lines
+  call feedkeys("!!sort\<CR>", 'xt')
+  call assert_equal([
+        \ 'Section 1',
+        \ '   brown',
+        \ '   cow',
+        \ '   how',
+        \ '   now',
+        \ 'Section 2',
+        \ '   how',
+        \ '   now',
+        \ '   brown',
+        \ '   cow',
+        \ ], getline(1, 10))
+
+  bwipe!
+endfunc
+
 " vim: shiftwidth=2 sts=2 expandtab