Coc.nvim: CocUpdate command unsets scrolloff option.

Created on 3 Jun 2020  Â·  11Comments  Â·  Source: neoclide/coc.nvim

Result from CocInfo

## versions

vim version: NVIM v0.5.0-374-gd9657b3ae
node version: v10.20.1
coc.nvim version: 0.0.78-95e7ca8324
coc.nivm directory: /opt/vim.plugged/coc.nvim
term: xterm-256color
platform: linux

## Output channel: prettier

Describe the bug

When I run :CocInstall or :CocUpdate, my custom vim option scrolloff is reset to zero.

Reproduce the bug

  • Create file mini.vim with:

    set nocompatible
    set runtimepath^=/path/to/coc.nvim
    filetype plugin indent on
    syntax on
    set hidden
    
  • Start (neo)vim with command: vim -u mini.vim

  • run :set scrolloff=10

  • run :set scrolloff? (output: scrolloff=10)

  • run :CocUpdate or :CocInstall <any-coc-extension>, like :CocInstall coc-python or :CocInstall coc-rust-analyzer.

  • run :set scrolloff? again (output: scrolloff=0, expected 10 instead)

All 11 comments

The option change only affect install window.

Negative. It also affects the original window. Please reopen and consider reproducing again with this more fleshed example, while navigating coc's README.md

mini.vim

set nocompatible
set runtimepath^=/opt/vim.plugged/coc.nvim
filetype plugin indent on
syntax on
set hidden
  • $ wget https://raw.githubusercontent.com/neoclide/coc.nvim/master/README.md
  • $ nvim README.md -u mini.vim
  • :150<cr> to navigate somewhere in the middle of the file
  • :set scrolloff=10<cr>
  • Scroll with zt and zb, see how the cursor stops 10 lines before the top and bottom edges of the window.
  • :CocUpdate<cr>, the update/install window opens.
  • When update/installing is done, close update/install window with <c-w>o. This takes you back to README.md window.
  • Scroll again with zt and zb in the README.md window, see how the cursor now hit the top and bottom edges of the window.
  • :set scrolloff?<cr> yields 0 instead of 10, not only in the install window.

I don't understand the way issues are used in this repo, should I open another issue?

No, can't reproduce, try minimal vimrc

I reproduced.

On my setup scrolloff starts with 1, I set it to 10, after :CocUpdate it becomes 0, which was checked after closing the update window with q.

The only place scrolloff is found is here

https://github.com/neoclide/coc.nvim/blob/7e51963a0c56a7edc23de54083eb50c6bbfc0a28/src/model/installBuffer.ts#L123

It's using setl to set options only locally, but the option is global according to vimhelp.

So, there's no way to set it local, and global value gets set, but is not recovered.

Possibly care should be taken wherever this is being practiced, for any option that's global.

No, can't reproduce, try minimal vimrc

@chemzqm What's more minimal than the mini.vim I have tried?

Folks, hope you're OK with reopening this one as it's easy to reproduce and the code line with the issue has been pointed.

I think it's worth warning again this may be happening for other global-only settings too, here or elsewhere in the codebase.

:h :setlocal

Not all options have a local value. If the option does not have a local value the global value is set.

Was this page helpful?
0 / 5 - 0 ratings

Related issues

MacGuffinLife picture MacGuffinLife  Â·  4Comments

MaskRay picture MaskRay  Â·  3Comments

LinArcX picture LinArcX  Â·  4Comments

svenstaro picture svenstaro  Â·  4Comments

andys8 picture andys8  Â·  3Comments