mirror of
https://github.com/junegunn/limelight.vim.git
synced 2025-11-08 11:03:48 -05:00
Don't move the cursor to beginning of line on deactivating limelight (#60)
Calling functions in vim using a range with `<line1>,<line2>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.
This commit is contained in:
@@ -254,8 +254,8 @@ function! s:cleanup()
|
|||||||
end
|
end
|
||||||
endfunction
|
endfunction
|
||||||
|
|
||||||
function! limelight#execute(bang, visual, ...) range
|
function! limelight#execute(bang, visual, line1, line2, ...)
|
||||||
let range = a:visual ? [a:firstline, a:lastline] : []
|
let range = a:visual ? [a:line1, a:line2] : []
|
||||||
if a:bang
|
if a:bang
|
||||||
if a:0 > 0 && a:1 =~ '^!' && !s:is_on()
|
if a:0 > 0 && a:1 =~ '^!' && !s:is_on()
|
||||||
if len(a:1) > 1
|
if len(a:1) > 1
|
||||||
|
|||||||
@@ -21,7 +21,7 @@
|
|||||||
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
" OF CONTRACT, TORT OR OTHERWISE, ARISING FROM, OUT OF OR IN CONNECTION
|
||||||
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
" WITH THE SOFTWARE OR THE USE OR OTHER DEALINGS IN THE SOFTWARE.
|
||||||
|
|
||||||
command! -nargs=? -bar -bang -range Limelight <line1>,<line2>call limelight#execute(<bang>0, <count> > 0, <f-args>)
|
command! -nargs=? -bar -bang -range Limelight call limelight#execute(<bang>0, <count> > 0, <line1>, <line2>, <f-args>)
|
||||||
|
|
||||||
nnoremap <silent> <Plug>(Limelight) :set opfunc=limelight#operator<CR>g@
|
nnoremap <silent> <Plug>(Limelight) :set opfunc=limelight#operator<CR>g@
|
||||||
xnoremap <silent> <Plug>(Limelight) :Limelight<CR>
|
xnoremap <silent> <Plug>(Limelight) :Limelight<CR>
|
||||||
|
|||||||
Reference in New Issue
Block a user