From 815c6122504361d52e10172601471b416d040ca8 Mon Sep 17 00:00:00 2001 From: Tobias Witt Date: Mon, 7 Sep 2020 07:09:35 +0200 Subject: [PATCH] Don't move the cursor to beginning of line on deactivating limelight (#60) Calling functions in vim using a range with `,call ...` makes vim move the cursor to the beginning of the line. This can cause distraction when Limelight is used in conjunction with the insert mode (e.g. when deactivating on `InsertLeave`). This commit makes the `Limelight` command pass the range as parameters to the `execute` function which removes that effect while `Limelight`ening a range still works. --- autoload/limelight.vim | 4 ++-- plugin/limelight.vim | 2 +- 2 files changed, 3 insertions(+), 3 deletions(-) diff --git a/autoload/limelight.vim b/autoload/limelight.vim index 2ebfe0f..a5e5c7d 100644 --- a/autoload/limelight.vim +++ b/autoload/limelight.vim @@ -254,8 +254,8 @@ function! s:cleanup() end endfunction -function! limelight#execute(bang, visual, ...) range - let range = a:visual ? [a:firstline, a:lastline] : [] +function! limelight#execute(bang, visual, line1, line2, ...) + let range = a:visual ? [a:line1, a:line2] : [] if a:bang if a:0 > 0 && a:1 =~ '^!' && !s:is_on() if len(a:1) > 1 diff --git a/plugin/limelight.vim b/plugin/limelight.vim index 427e54e..9b9140f 100644 --- a/plugin/limelight.vim +++ b/plugin/limelight.vim @@ -21,7 +21,7 @@ " OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION " WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE. -command! -nargs=? -bar -bang -range Limelight ,call limelight#execute(0, > 0, ) +command! -nargs=? -bar -bang -range Limelight call limelight#execute(0, > 0, , , ) nnoremap (Limelight) :set opfunc=limelight#operatorg@ xnoremap (Limelight) :Limelight