mirror of
https://github.com/jdhao/nvim-config.git
synced 2025-06-08 14:14:33 +02:00
fix bug in go to last edit position
If a go-to-line command is given, do not go to last edit position for the file.
This commit is contained in:
parent
ed52ca5914
commit
08d3d7ec08
@ -22,10 +22,25 @@ augroup END
|
|||||||
" Return to last edit position when opening a file
|
" Return to last edit position when opening a file
|
||||||
augroup resume_edit_position
|
augroup resume_edit_position
|
||||||
autocmd!
|
autocmd!
|
||||||
autocmd BufReadPost *
|
autocmd BufReadPost * call s:resume_edit_pos()
|
||||||
\ if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit' | execute "normal! g`\"zvzz" | endif
|
|
||||||
augroup END
|
augroup END
|
||||||
|
|
||||||
|
" Only resume last edit position when there is no go-to-line command (something like '+23').
|
||||||
|
function s:resume_edit_pos() abort
|
||||||
|
if line("'\"") > 1 && line("'\"") <= line("$") && &ft !~# 'commit'
|
||||||
|
let l:args = v:argv " command line arguments
|
||||||
|
for l:cur_arg in l:args
|
||||||
|
" Check if a go-to-line command is given.
|
||||||
|
let idx = match(l:cur_arg, '\v^\+(\d){1,}$')
|
||||||
|
if idx != -1
|
||||||
|
return
|
||||||
|
endif
|
||||||
|
endfor
|
||||||
|
|
||||||
|
execute "normal! g`\"zvzz"
|
||||||
|
endif
|
||||||
|
endfunction
|
||||||
|
|
||||||
" Display a message when the current file is not in utf-8 format.
|
" Display a message when the current file is not in utf-8 format.
|
||||||
" Note that we need to use `unsilent` command here because of this issue:
|
" Note that we need to use `unsilent` command here because of this issue:
|
||||||
" https://github.com/vim/vim/issues/4379
|
" https://github.com/vim/vim/issues/4379
|
||||||
|
|||||||
Loading…
x
Reference in New Issue
Block a user