Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

cbuffer/cad doesn't take visual selection as range '<,'>cad #14638

Closed
ilan-schemoul opened this issue Apr 25, 2024 · 5 comments
Closed

cbuffer/cad doesn't take visual selection as range '<,'>cad #14638

ilan-schemoul opened this issue Apr 25, 2024 · 5 comments
Labels

Comments

@ilan-schemoul
Copy link

Steps to reproduce

select something
type '<,'>cad
=> E16: Invalid range

Expected behaviour

Should take visual range (like it takes regular range such as 1cad).
Btw in the issue #2955 you can see it's advised by someone to do such things as '<,'>cgetbuffer (very useful because as explained in the issue when you have a terminal running inside vim you regularly want to take the output of the command and put it in the fixlist)

Version of Vim

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar 14 2024 09:05:11) Included patches: 1-579, 1969, 580-1848, 4975, 5016, 5023, 5072, 2068, 1849-1854, 1857, 1855-1857, 1331, 1858, 1858-1859, 1873, 1860-1969, 1992, 1970-1992, 2010, 1993-2068, 2106, 2069-2106, 2108, 2107-2109, 2109-3995, 4563, 4646, 4774, 4895, 4899, 4901, 4919, 213, 1840, 1846-1847, 2110-2112, 2121

Environment

xterm-256color
WSL 2 ubuntu 22.04
windows terminal

Logs and stack traces

No response

@vim-ml
Copy link

vim-ml commented Apr 26, 2024 via email

@ilan-schemoul
Copy link
Author

ilan-schemoul commented Apr 26, 2024

Hey,

Version of Vim

VIM - Vi IMproved 8.2 (2019 Dec 12, compiled Mar 14 2024 09:05:11)
Included patches: 1-579, 1969, 580-1848, 4975, 5016, 5023, 5072, 2068,
1849-1854, 1857, 1855-1857, 1331, 1858, 1858-1859, 1873, 1860-1969, 1992,
1970-1992, 2010, 1993-2068, 2106, 2069-2106, 2108, 2107-2109, 2109-3995,
4563, 4646, 4774, 4895, 4899, 4901, 4919, 213, 1840, 1846-1847, 2110-2112,
2121
This looks weird and ugly (that's not your fault!).

I do not know why it's like this. I believe I kept the default vim as packaged by default on ubuntu 22.04 on WSL 2. I agree it can be improved :)

Oh, I just realized: this is an old version (8.2, from 2019). Is there a
newer version you can try?

I just compiled the latest version on master on another computer with Ubuntu 22.04 and I can confirm I have the same error with configuration disabled (-u none) and selecting something and executing the command :'<,'>cad (or cgetbuffer)

I am surprised you confirm it seems like a bug (present already in my version from 2019 and still here in 2024) and not a misunderstanding on my side as visual range selecting is very common and I can't believe I can be the only one trying to use quickfix lists with visual selection.

@chrisbra
Copy link
Member

Hm, even the mentioned '<,'>cgetbuffer does no longer work. It seems at least the following two commands would need to use ADDR_LINES instead of ADDR_OTHER.

Something like this:

diff --git a/src/ex_cmds.h b/src/ex_cmds.h
index 70e57708f..bd195a72f 100644
--- a/src/ex_cmds.h
+++ b/src/ex_cmds.h
@@ -271,7 +271,7 @@ EXCMD(CMD_cabove,   "cabove",       ex_cbelow,
        ADDR_UNSIGNED),
 EXCMD(CMD_caddbuffer,  "caddbuffer",   ex_cbuffer,
        EX_RANGE|EX_WORD1|EX_TRLBAR,
-       ADDR_OTHER),
+       ADDR_LINES),
 EXCMD(CMD_caddexpr,    "caddexpr",     ex_cexpr,
        EX_NEEDARG|EX_WORD1|EX_NOTRLCOM|EX_EXPR_ARG,
        ADDR_NONE),
@@ -331,7 +331,7 @@ EXCMD(CMD_cgetfile, "cgetfile",     ex_cfile,
        ADDR_NONE),
 EXCMD(CMD_cgetbuffer,  "cgetbuffer",   ex_cbuffer,
        EX_RANGE|EX_WORD1|EX_TRLBAR,
-       ADDR_OTHER),
+       ADDR_LINES),
 EXCMD(CMD_cgetexpr,    "cgetexpr",     ex_cexpr,
        EX_NEEDARG|EX_WORD1|EX_NOTRLCOM|EX_EXPR_ARG,
        ADDR_NONE),

It seems ADDR_OTHER doesn't make sense here. @yegappan what do you think?

@vim-ml
Copy link

vim-ml commented Apr 27, 2024 via email

chrisbra added a commit to chrisbra/vim that referenced this issue Apr 28, 2024
Problem:  cgetbuffer/caddbuffer doesn't accept a range
          (ilan-schemoul after 8.1.1241)
Solution: Define ex commands with ADDR_LINES instead of ADDR_OTHER

fixes: vim#14638

Signed-off-by: Christian Brabandt <cb@256bit.org>
chrisbra added a commit to chrisbra/vim that referenced this issue Apr 28, 2024
Problem:  cgetbuffer/caddbuffer doesn't accept a range
          (ilan-schemoul after 8.1.1241)
Solution: Define ex commands with ADDR_LINES instead of ADDR_OTHER

fixes: vim#14638

Signed-off-by: Christian Brabandt <cb@256bit.org>
@chrisbra
Copy link
Member

I created #14657 for this.

chrisbra added a commit to chrisbra/vim that referenced this issue Apr 28, 2024
Problem:  cgetbuffer/caddbuffer doesn't accept a range
          (ilan-schemoul after 8.1.1241)
Solution: Define ex commands with ADDR_LINES instead of ADDR_OTHER

fixes: vim#14638

Signed-off-by: Christian Brabandt <cb@256bit.org>
chrisbra added a commit to chrisbra/vim that referenced this issue Apr 29, 2024
Problem:  cgetbuffer/caddbuffer doesn't accept a range
          (ilan-schemoul after 8.1.1241)
Solution: Define ex commands with ADDR_LINES instead of ADDR_OTHER

fixes: vim#14638

Signed-off-by: Christian Brabandt <cb@256bit.org>
zeertzjq added a commit to zeertzjq/neovim that referenced this issue Apr 29, 2024
Problem:  cbuffer and similar quickfix and locationlist commands don't
          accept a range, even so it is documented they should
          (ilan-schemoul, after 8.1.1241)
Solution: Define ex commands with ADDR_LINES instead of ADDR_OTHER

fixes: vim/vim#14638
closes: vim/vim#14657

vim/vim@652c821

Co-authored-by: Christian Brabandt <cb@256bit.org>
zeertzjq added a commit to neovim/neovim that referenced this issue Apr 29, 2024
…#28571)

Problem:  cbuffer and similar quickfix and locationlist commands don't
          accept a range, even so it is documented they should
          (ilan-schemoul, after 8.1.1241)
Solution: Define ex commands with ADDR_LINES instead of ADDR_OTHER

fixes: vim/vim#14638
closes: vim/vim#14657

vim/vim@652c821

Co-authored-by: Christian Brabandt <cb@256bit.org>
phanen pushed a commit to phanen/neovim that referenced this issue May 3, 2024
…neovim#28571)

Problem:  cbuffer and similar quickfix and locationlist commands don't
          accept a range, even so it is documented they should
          (ilan-schemoul, after 8.1.1241)
Solution: Define ex commands with ADDR_LINES instead of ADDR_OTHER

fixes: vim/vim#14638
closes: vim/vim#14657

vim/vim@652c821

Co-authored-by: Christian Brabandt <cb@256bit.org>
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants