From b92a2224cd5980f5946b0d8e50a8f574a259dd6f Mon Sep 17 00:00:00 2001 From: Marco Hinz Date: Wed, 10 Apr 2019 18:52:13 +0200 Subject: [PATCH] Don't change line on Fixes https://github.com/mhinz/vim-startify/issues/365 --- autoload/startify.vim | 15 +++++++++++++-- 1 file changed, 13 insertions(+), 2 deletions(-) diff --git a/autoload/startify.vim b/autoload/startify.vim index 9b291c7..c96b702 100644 --- a/autoload/startify.vim +++ b/autoload/startify.vim @@ -772,11 +772,14 @@ function! s:set_cursor() abort let b:startify.newline = line('.') " going up (-1) or down (1) - if b:startify.oldline == b:startify.newline && col('.') != s:fixed_column + if b:startify.oldline == b:startify.newline + \ && col('.') != s:fixed_column + \ && !b:startify.leftmouse let movement = 2 * (col('.') > s:fixed_column) - 1 let b:startify.newline += movement else - let movement = 2 * (b:startify.newline > b:startify.oldline) - 1 + let movement = 2 * (b:startify.newline > b:startify.oldline) - 1 + let b:startify.leftmouse = 0 endif " skip section headers lines until an entry is found @@ -804,6 +807,7 @@ function! s:set_mappings() abort nnoremap t :call set_mark('T') nnoremap v :call set_mark('V') nnoremap :call startify#open_buffers() + nnoremap :call leftmouse() nnoremap <2-LeftMouse> :call startify#open_buffers() nnoremap :enew execute 'normal! "'.(v:register=='"'?'*':v:register).'gp' @@ -812,6 +816,13 @@ function! s:set_mappings() abort nnoremap n ' j'[v:searchforward].'n' nnoremap N 'j '[v:searchforward].'N' + function! s:leftmouse() + " feedkeys() triggers CursorMoved which calls s:set_cursor() which checks + " .leftmouse. + let b:startify.leftmouse = 1 + call feedkeys("\", 'nt') + endfunction + function! s:compare_by_index(foo, bar) return a:foo.index - a:bar.index endfunction