Allow :LSClientFindActions with visual selection#179
Allow :LSClientFindActions with visual selection#179
Conversation
Towards #178 Uses a hack to try to figure out if the user is likely to have set reasonable marks for the range and is running from a visual selection so that lines were passed with `:'<,'>LSClientFindCodeActions`.
| endif | ||
| call lsc#file#flushChanges() | ||
| let params = lsc#params#documentRange() | ||
| let l:usingRange = a:0 > 2 && (a:2 != 1 || a:3 != line('$')) |
There was a problem hiding this comment.
Why do you need to check a:2 != 1 || a:3 != line('$')?
There was a problem hiding this comment.
This was my hack to know whether we were called with a range. If we're called like :LSClientFindCodeActions then the -range=% at the command definition will fill in 1,$ and we're identifying that case here. If we're called like :'<,'>LSClientFindCodeActions then it shouldn't match 1,$ and we'd know to actually look at the visual selection marks.
It does mean you can't actually do :1,$LSClientFindCodeActions and pass the entire doc in the range to the server...
There was a problem hiding this comment.
Should it be && instead of || then?
Also sending the whole document range can be useful. Example: wrapping code in IIFE.
Maybe it is better to expose function with argument isRange and use it in keybindings instead of command which tries to guess visual mode?
I use this one
vnoremap <silent> ga :call lsc#edit#findCodeActions(lsc#edit#filterActions(), 0, 0)<CR>
|
Hi! Are you going to merge this? Or you looking for another solution? Can I help you somehow? |
|
Sorry for the slow reply - I'd like to play with this a bit more before merging. I'd prefer to avoid a situation where it's necessary to map directly to Is a keymap your preferred way to use this? We could also explore support for visual mode mappings in the config and a way to pass a flag to tell it explicitly that it's using visual mode. |
|
@natebosch don't worry. I understand that this is an open source project and you work on it when you have time 👍 Yes, keymap is a preferred way. I'm using actions quite a lot and it doesn't make sense to type command every time. As a user I would like to use the same keybingind ( I hope it helps. |
Towards #178
Uses a hack to try to figure out if the user is likely to have set
reasonable marks for the range and is running from a visual selection so
that lines were passed with
:'<,'>LSClientFindCodeActions.