Continued from #106. Cursor position syncing fails in vim 8 when the top window line is not the first line of the file.
Here's an example before editing text:
Then after editing text, the LHS shows the first line of the file (note I use a rephraser to add equals markings):
The cursor position is only preserved if I ensure codi#update is only ever invoked from the first line using the following function definition and custom autocommands:
" Define kludge
function! s:codi_kludge(trigger)
return
if a:trigger
let winline = line('w0')
if winline > 1
let s:codi_view = winsaveview()
keepjumps 1 " jump to first line
endif
else
if exists('s:codi_view')
call winrestview(s:codi_view)
unlet s:codi_view
normal! kj
endif
endif
endfunction
" Add autocommands
augroup codi_mods
au!
au User CodiUpdatePre call s:codi_kludge(1)
au User CodiUpdatePost call s:codi_kludge(0)
augroup END
I also turn on synchronous mode with let g:codi#sync = 1 so that this "kludge" does not cause vim to show the cursor briefly jumping to the first line (which results from the async delay -- otherwise, with set lazyredraw, the cursor movement is not shown). Note that synchronous mode does not resolve this bug.
Tried to implement the "kludge" inside s:codi_handle_done, which I noticed already does lots of line/cursor jumping, but for some reason I couldn't get it to work. Really seems like it should though, since I'm just implementing the exact same logic as in these autocommands... and in fact your existing s:codi_handle_done already has a similar logic...
```
Finished. 0 error(s).
[=============================================================]
- denops.vim: OK
- vim-textobj-line: OK
- vim-tmux: OK
- vim-characterize: OK
- applescript.vim: OK
- vim-toml: OK
- ddc-around: OK
- tcomment_vim: OK
- vim-lsp: OK
- vim-autoformat: OK
- braceless.vim: OK
- vim-easy-align: OK
- undotree: OK
- vim-cython: OK
- vim-markdown: OK
- vim-eunuch: OK
- vim-matchup: OK
- vim-textobj-indent: OK
- ddc-fuzzy: OK
- vim-autopep8: OK
- jupytext.vim: OK
- vim-superman: OK
- ddc-file: OK
- vim-obsession: OK
- gv.vim: OK
- vim-sneak: OK
- vim-colorschemes: OK
- close-buffers.vim: OK
- vim-gitgutter: OK
- vim-fahrenheit: OK
- HowMuch: OK
- vim-isort: OK
- vim-textobj-user: OK
- ddc-buffer: OK
- vim-lsp-ale: OK
- vim-vsnip-integ: OK
- FastFold: OK
- vim-fugitive: OK
- denops-popup-preview.vim: OK
- colorizer: OK
- yowish.vim: OK
- vim-test: OK
- vim-vsnip: OK
- vim-textobj-parameter: OK
- vim-speeddating: OK
- vim-liquid: OK
- ale: OK
- .fzf: OK
- jedi-vim: OK
- fzf.vim: OK
- black: OK
- splitjoin.vim: OK
- jupyter-vim: OK
- delimitmate: OK
- vim-textobj-entire: OK
- ddc-vim-lsp: OK
- vim-surround: OK
- codi.vim: OK
- julia-vim: OK
- vim-lsp-settings: OK
- ddc.vim: OK
```
Issue description
Continued from #106. Cursor position syncing fails in vim 8 when the top window line is not the first line of the file.
Here's an example before editing text:
Then after editing text, the LHS shows the first line of the file (note I use a rephraser to add equals markings):
The cursor position is only preserved if I ensure
codi#update
is only ever invoked from the first line using the following function definition and custom autocommands:I also turn on synchronous mode with
let g:codi#sync = 1
so that this "kludge" does not cause vim to show the cursor briefly jumping to the first line (which results from the async delay -- otherwise, withset lazyredraw
, the cursor movement is not shown). Note that synchronous mode does not resolve this bug.Tried to implement the "kludge" inside
s:codi_handle_done
, which I noticed already does lots of line/cursor jumping, but for some reason I couldn't get it to work. Really seems like it should though, since I'm just implementing the exact same logic as in these autocommands... and in fact your existings:codi_handle_done
already has a similar logic...Environment
Operating system: macOS 12.1
Vim version:
Plugins (result of
:PlugStatus
fromvim-plug
):