diff options
author | zeertzjq <zeertzjq@outlook.com> | 2022-11-12 07:43:36 +0800 |
---|---|---|
committer | GitHub <noreply@github.com> | 2022-11-12 07:43:36 +0800 |
commit | eee956051637a5dff02ba6c6083fbffc87c0c96e (patch) | |
tree | bd08a4983f10ffe914ce0c668e1d7b4a5ed4337d /src/nvim/ex_docmd.c | |
parent | 0d7cc5ee85c2722ab68e276a2bfda336ef9429d5 (diff) | |
download | rneovim-eee956051637a5dff02ba6c6083fbffc87c0c96e.tar.gz rneovim-eee956051637a5dff02ba6c6083fbffc87c0c96e.tar.bz2 rneovim-eee956051637a5dff02ba6c6083fbffc87c0c96e.zip |
vim-patch:9.0.0861: solution for "!!sort" in closed fold is not optimal (#21027)
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 vim/vim#11487)
https://github.com/vim/vim/commit/9954dc39ea090cee6bf41c888c41e60d9f52c3b8
Co-authored-by: Bram Moolenaar <Bram@vim.org>
Diffstat (limited to 'src/nvim/ex_docmd.c')
-rw-r--r-- | src/nvim/ex_docmd.c | 21 |
1 files changed, 4 insertions, 17 deletions
diff --git a/src/nvim/ex_docmd.c b/src/nvim/ex_docmd.c index f4100272e1..b875aafaad 100644 --- a/src/nvim/ex_docmd.c +++ b/src/nvim/ex_docmd.c @@ -3224,8 +3224,6 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int char *cmd = skipwhite(*ptr); linenr_T lnum = MAXLNUM; do { - const int base_char = (uint8_t)(*cmd); - switch (*cmd) { case '.': // '.' - Cursor position cmd++; @@ -3502,16 +3500,10 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int } else if (addr_type == ADDR_LOADED_BUFFERS || addr_type == ADDR_BUFFERS) { lnum = compute_buffer_local_count(addr_type, lnum, (i == '-') ? -1 * n : n); } else { - // 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. - bool 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); } if (i == '-') { @@ -3522,11 +3514,6 @@ static linenr_T get_address(exarg_T *eap, char **ptr, cmd_addr_T addr_type, int goto error; } lnum += n; - // ".+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); - } } } } |