Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

coc-rename - moves the cursor to the start of the first line #4922

Closed
ObiWahn opened this issue Mar 3, 2024 · 9 comments
Closed

coc-rename - moves the cursor to the start of the first line #4922

ObiWahn opened this issue Mar 3, 2024 · 9 comments

Comments

@ObiWahn
Copy link

ObiWahn commented Mar 3, 2024

Result from CocInfo

1 ## versions
2
3 vim version: VIM - Vi IMproved 9.1 9010016
4 node version: v18.5.0
5 coc.nvim version: 0.0.82-bd303cf7 2024-03-01 18:31:10 +0800
6 coc.nvim directory: /home/obiwahn/.vim/bundles/available-github/coc.nvim
7 term: tmux
8 platform: linux
9
10 ## Log of coc.nvim
11
12 2024-03-03T13:53:10.872 WARN (pid:70141) [workspace] - Extension "coc-lists" registered synchronized autocmd "VimLeavePre", which could be slow.
13 2024-03-03T13:53:10.911 INFO (pid:70141) [plugin] - coc.nvim initialized with node: v18.5.0 after 293
14 2024-03-03T13:53:15.615 INFO (pid:70141) [attach] - receive notification: showInfo []
15

Describe the bug

When starting a rename via (coc-rename) my buffer moves to the very top and as soon as the rename is done the cursor is not on the renamed word, but at the beginning of the first line.

Reproduce the bug

Please provide more information. I have moved my original directory out of the way and create a new dir.

» cat ~/mini.vim
set nocompatible  <<-- // ADD THIS TO YOUR INSTRUCTIONS FOR REGULAR VIM
set runtimepath^=/home/obiwahn/coc.nvim
filetype plugin indent on
syntax on
set hidden
map      <silent><F8>        <Plug>(coc-rename)
map!     <silent><F8>   <C-O><Plug>(coc-rename)

Open some random c++ project and press F8 to rename variable

Screenshots

screenshot_2024-03-03_14:48:34
screenshot_2024-03-03_14:48:57

Actually when I added the set nocompatible (without it coc is broken) I had moved my .vim dir already back. I wonder if it is ok to see the airline plugin here. On the other hand not all configurations have been loaded as I had to use :set numbers which is usually always on.

UPDATE
No it is not:
screenshot_2024-03-03_15:01:19
Please update the instructions.

@ObiWahn
Copy link
Author

ObiWahn commented Mar 3, 2024

I would still love to hear what you think could break the menu. Or give me some advice on how to debug the problem.

@ObiWahn
Copy link
Author

ObiWahn commented Mar 3, 2024

Since the editorconfig package is part of the vim distribution and coc misbehaves if it is installed, I think it would be good if you would help resolving the issue.

set nocompatible
packadd! editorconfig
set runtimepath^=/home/obiwahn/nobackup/coc-test/coc.nvim
filetype plugin indent on
syntax on
set hidden
map      <silent><F8>        <Plug>(coc-rename)
map!     <silent><F8>   <C-O><Plug>(coc-rename)

@ObiWahn ObiWahn reopened this Mar 3, 2024
@ObiWahn ObiWahn changed the title coc-rename - moves the cursor to the start of the the first line coc-rename - moves the cursor to the start of the first line Mar 3, 2024
@fannheyward
Copy link
Member

Tested with vim 9.1 with your mini vimrc, can't reproduce it.

vim version: VIM - Vi IMproved 9.1 9010100
node version: v21.6.2
coc.nvim version: 0.0.82-bd303cf7 2024-03-01 18:31:10 +0800
coc.nvim directory: /Users/fannheyward/.local/share/nvim/plugged/coc.nvim
term: iTerm.app
platform: darwin


set nocompatible
packadd! editorconfig
set runtimepath^=~/.local/share/nvim/plugged/coc.nvim
set runtimepath^=~/src/coc-clangd
filetype plugin indent on
syntax on
set hidden

nmap <silent> gn <Plug>(coc-rename)

@wickedmic
Copy link

Hey everyone, I was able to reproduce the issue as described by @ObiWahn. When I use the following vimrc the rename dialog box appears at the top of the screen and my buffer is scrolled all the way to the top.

set nocompatible
packadd! editorconfig
set runtimepath^=/home/nandu/.vim/pack/plugins/start/coc.nvim
filetype plugin indent on
syntax on
set hidden
map      <silent><F8>        <Plug>(coc-rename)
map!     <silent><F8>   <C-O><Plug>(coc-rename)

When I remove the line packadd! editorconfig the issue goes away (rename dialog box is at the line where the cursor was and my buffer stays where it was).

Here is my setup

vim --version
VIM - Vi IMproved 9.1 (2024 Jan 02, compiled Jan 11 2024 20:38:16)
Included patches: 1-16
Modified by team+vim@tracker.debian.org
Compiled by team+vim@tracker.debian.org
Huge version without GUI.  Features included (+) or not (-):
+acl               +file_in_path      +mouse_urxvt       -tag_any_white
+arabic            +find_in_path      +mouse_xterm       -tcl
+autocmd           +float             +multi_byte        +termguicolors
+autochdir         +folding           +multi_lang        +terminal
-autoservername    -footer            -mzscheme          +terminfo
-balloon_eval      +fork()            +netbeans_intg     +termresponse
+balloon_eval_term +gettext           +num64             +textobjects
-browse            -hangul_input      +packages          +textprop
++builtin_terms    +iconv             +path_extra        +timers
+byte_offset       +insert_expand     -perl              +title
+channel           +ipv6              +persistent_undo   -toolbar
+cindent           +job               +popupwin          +user_commands
-clientserver      +jumplist          +postscript        +vartabs
-clipboard         +keymap            +printer           +vertsplit
+cmdline_compl     +lambda            +profile           +vim9script
+cmdline_hist      +langmap           -python            +viminfo
+cmdline_info      +libcall           -python3           +virtualedit
+comments          +linebreak         +quickfix          +visual
+conceal           +lispindent        +reltime           +visualextra
+cryptv            +listcmds          +rightleft         +vreplace
+cscope            +localmap          -ruby              +wildignore
+cursorbind        -lua               +scrollbind        +wildmenu
+cursorshape       +menu              +signs             +windows
+dialog_con        +mksession         +smartindent       +writebackup
+diff              +modify_fname      +sodium            -X11
+digraphs          +mouse             -sound             +xattr
-dnd               -mouseshape        +spell             -xfontset
-ebcdic            +mouse_dec         +startuptime       -xim
+emacs_tags        +mouse_gpm         +statusline        -xpm
+eval              -mouse_jsbterm     -sun_workshop      -xsmp
+ex_extra          +mouse_netterm     +syntax            -xterm_clipboard
+extra_search      +mouse_sgr         +tag_binary        -xterm_save
-farsi             -mouse_sysmouse    -tag_old_static    
   system vimrc file: "/etc/vim/vimrc"
     user vimrc file: "$HOME/.vimrc"
 2nd user vimrc file: "~/.vim/vimrc"
      user exrc file: "$HOME/.exrc"
       defaults file: "$VIMRUNTIME/defaults.vim"
  fall-back for $VIM: "/usr/share/vim"
Compilation: gcc -c -I. -Iproto -DHAVE_CONFIG_H -Wdate-time -g -O2 -ffile-prefix-map=/build/reproducible-path/vim-9.1.0016=. -fstack-protector-strong -fstack-clash-protection -Wformat -Werror=format-security -fcf-protection -DSYS_VIMRC_FILE=\"/etc/vim/vimrc\" -DSYS_GVIMRC_FILE=\"/etc/vim/gvimrc\" -D_REENTRANT -U_FORTIFY_SOURCE -D_FORTIFY_SOURCE=1 
Linking: gcc -Wl,-z,relro -Wl,-z,now -Wl,--as-needed -o vim -lm -ltinfo -lselinux -lsodium -lacl -lattr -lgpm
contents of :CocInfo
## versions

vim version: VIM - Vi IMproved 9.1 9010016
node version: v18.19.1
coc.nvim version: 0.0.82-d1568d56 2023-09-29 19:43:34 +0800
coc.nvim directory: /home/nandu/.vim/pack/plugins/start/coc.nvim
term: dumb
platform: linux

## Log of coc.nvim

2024-03-06T10:33:19.160 INFO (pid:47524) [plugin] - coc.nvim initialized with node: v18.19.1 after 365
2024-03-06T10:33:19.178 INFO (pid:47524) [services] - LanguageClient clangd state change: stopped => starting
2024-03-06T10:33:19.183 INFO (pid:47524) [language-client-index] - Language server "clangd" started with 47543
2024-03-06T10:33:19.258 INFO (pid:47524) [services] - LanguageClient clangd state change: starting => running
2024-03-06T10:33:19.273 INFO (pid:47524) [services] - service clangd started
2024-03-06T10:33:20.947 INFO (pid:47524) [attach] - receive notification: showInfo []

@fannheyward
Copy link
Member

0.0.82-d1568d56 2023-09-29 19:43:34 +0800

@wickedmic upgrade your coc.nvim and try again.

@fannheyward
Copy link
Member

Still can't reproduce with packadd! editorconfig, Vi IMproved 9.1 9010150

@ObiWahn
Copy link
Author

ObiWahn commented Mar 6, 2024

I can not reproduce the problem on mac with the latest homebrew vim. But it still happens on linux with the version in Debian/Sid.

@basilgood
Copy link

It's reproducible on linux but in my case only in tsserver (coc-tsserver). In nil (nix-language-server) it works perfectly.
vim --version: VIM - Vi IMproved 9.1 Included patches: 1-173.
With sgur/vim-editorconfig it works everywhere, only with packadd editorconfig the problem occurs but only with tsserver in my case.
Thanks for your work!

@fannheyward
Copy link
Member

vim's packed editorconfig is outdated.

  1. vim packed editorconfig/editorconfig-vim in runtime: Distribute the editorconfig with vim vim/vim#12902, commit editorconfig/editorconfig-vim@e014708
  2. Cursor moves back to beginning of line when exiting :FZF popup on Vim 9 (after #209) editorconfig/editorconfig-vim#224 same issue, fixed in Don't set tabstop in shell buffers (#224) editorconfig/editorconfig-vim#229 and Fix typo editorconfig/editorconfig-vim#230

But it's strange that, vim built with brew on macOS can't reproduce this.

Don't use packadd! editorconfig, use https://github.com/editorconfig/editorconfig-vim directly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

4 participants