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

Calling the linewise comment toggle on multiple lines with visual mode loses selection #113

Closed
jmiln opened this issue Feb 3, 2022 · 2 comments
Labels
question Question related to integration and other stuff

Comments

@jmiln
Copy link

jmiln commented Feb 3, 2022

If you select multiple lines in visual mode, then run the command documented in the api page (Shown below), then typing gv to reselect previous selection only reselects the starting line, and not the entire selection.

This happens when typing in the lua command manually too, not just when having it mapped.

-- Linewise toggle using C-/
map('x', '<C-_>', '<ESC><CMD>lua require("Comment.api").toggle_linewise_op(vim.fn.visualmode())<CR>')
@numToStr
Copy link
Owner

numToStr commented Feb 3, 2022

If you select multiple lines in visual mode, then run the command documented in the api page (Shown below), then typing gv to reselect previous selection only reselects the starting line, and not the entire selection.

Yes, the API functions does not preserve marks by default.

Try

-- Linewise toggle using C-/
map('x', '<C-_>', '<ESC><CMD>lua require("Comment.api").locked.toggle_linewise_op(vim.fn.visualmode())<CR>')

@numToStr numToStr added the question Question related to integration and other stuff label Feb 3, 2022
@jmiln
Copy link
Author

jmiln commented Feb 3, 2022

Awesome, that works perfectly.
Thanks!

@jmiln jmiln closed this as completed Feb 3, 2022
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
question Question related to integration and other stuff
Projects
None yet
Development

No branches or pull requests

2 participants