diff src/ex_docmd.c @ 31053:39f96b1e7b8d v9.0.0861

patch 9.0.0861: solution for "!!sort" in closed fold is not optimal Commit: https://github.com/vim/vim/commit/9954dc39ea090cee6bf41c888c41e60d9f52c3b8 Author: Bram Moolenaar <Bram@vim.org> Date: Fri Nov 11 22:58:36 2022 +0000 patch 9.0.0861: solution for "!!sort" in closed fold is not optimal Problem: Solution for "!!sort" in closed fold is not optimal. Solution: Use a different range instead of the subtle difference in handling a range with an offset. (issue #11487)
author Bram Moolenaar <Bram@vim.org>
date Sat, 12 Nov 2022 00:00:04 +0100
parents bee731901f4f
children f6d4c6a3b41c
line wrap: on
line diff
--- a/src/ex_docmd.c
+++ b/src/ex_docmd.c
@@ -4308,9 +4308,6 @@ get_address(
     lnum = MAXLNUM;
     do
     {
-#ifdef FEAT_FOLDING
-	int base_char = *cmd;
-#endif
 	switch (*cmd)
 	{
 	    case '.':			    // '.' - Cursor position
@@ -4631,16 +4628,10 @@ get_address(
 	    else
 	    {
 #ifdef FEAT_FOLDING
-		// Relative line addressing: need to adjust for closed folds
-		// after the first address.
-		// Subtle difference: "number,+number" and "number,-number"
-		// adjusts to end of closed fold before adding/subtracting,
-		// while "number,.+number" adjusts to end of closed fold after
-		// adding to make "!!" expanded into ".,.+N" work correctly.
-		int adjust_for_folding = addr_type == ADDR_LINES
-						      && (i == '-' || i == '+')
-						      && address_count >= 2;
-		if (adjust_for_folding && (i == '-' || base_char != '.'))
+		// Relative line addressing: need to adjust for lines in a
+		// closed fold after the first address.
+		if (addr_type == ADDR_LINES && (i == '-' || i == '+')
+							 && address_count >= 2)
 		    (void)hasFolding(lnum, NULL, &lnum);
 #endif
 		if (i == '-')
@@ -4653,12 +4644,6 @@ get_address(
 			goto error;
 		    }
 		    lnum += n;
-#ifdef FEAT_FOLDING
-		    // ".+number" rounds up to the end of a closed fold after
-		    // adding, so that ":!!sort" sorts one closed fold.
-		    if (adjust_for_folding && base_char == '.')
-			(void)hasFolding(lnum, NULL, &lnum);
-#endif
 		}
 	    }
 	}