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

Moving to a fold with a 'gk' and then opening fold lands you on last line of fold #15490

Closed
jghauser opened this issue Aug 26, 2021 · 9 comments · Fixed by #22320
Closed

Moving to a fold with a 'gk' and then opening fold lands you on last line of fold #15490

jghauser opened this issue Aug 26, 2021 · 9 comments · Fixed by #22320
Labels
bug-vim wrong behavior inherited from vim folds
Milestone

Comments

@jghauser
Copy link

Neovim version (nvim -v)

NVIM v0.6.0-dev+182-ga373ca1d8

Vim (not Nvim) behaves the same?

yes, vim 8.2.2891

Operating system/version

Arch Linux

Terminal name/version

kitty 0.23.1

$TERM environment variable

xterm-kitty

Installation

AUR

How to reproduce the issue

  1. Save the following as test.txt:
{{{

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

}}}
{{{

Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.
Lorem ipsum dolor sit amet, consetetur sadipscing elitr, sed diam nonumy eirmod tempor invidunt ut labore et dolore magna aliquyam erat, sed diam voluptua. At vero eos et accusam et justo duo dolores et ea rebum. Stet clita kasd gubergren, no sea takimata sanctus est Lorem ipsum dolor sit amet.

}}}
  1. Open the file with nvim -u NORC test.txt or nvim -u NONE text.txt
  2. Run :set foldmethod=marker
  3. Move to bottom with G
  4. Move up with gk
  5. Open fold with zo

Expected behavior

The cursor should (just as when moving up with k) be on the first line of the fold.

Actual behavior

The cursor is on the last line of the fold.

@jghauser jghauser added the bug issues reporting wrong behavior label Aug 26, 2021
@justinmk justinmk added this to the backlog milestone Aug 26, 2021
@gabrielsrd
Copy link

I tried do reproduce the issue on Ubuntu 20.04.2 LTS and it worked as expected. Did you try reproducing this issue in another operating system?

@jghauser
Copy link
Author

Unfortunately, I don't have easy access to a computer with a different operating system. I'll try in the next days and will report back when I do!

@jghauser
Copy link
Author

It only happens with wrap enabled. Do you maybe have it set to nowrap?

@justinmk
Copy link
Member

@jghauser can you verify that the settings are the same in vim and nvim. compare the output of:

:set

(ignore the 'runtimepath' part)

@jghauser
Copy link
Author

jghauser commented Sep 5, 2021

I finally got around to checking this. Running vim -u DEFAULTS and nvim -u NONE have slightly different settings, though I don't think these should have an impact. Here's what I get with :set

nvim:

--- Options ---
  columns=106         lines=58            scroll=28
  helplang=en       noloadplugins         window=57
  fileencoding=utf-8

vim:

--- Options ---
  background=dark     history=200         mouse=a             showcmd             ttymouse=sgr
  commentstring=      incsearch           nrformats=bin,hex   syntax=text         wildmenu
  display=truncate    langnoremap         ruler               ttimeout
  filetype=text     nolangremap           scroll=28           ttimeoutlen=100
  helplang=en       noloadplugins         scrolloff=5         ttyfast
  backspace=indent,eol,start
  comments=fb:-,fb:*,n:>
  fileencoding=utf-8
  fileencodings=ucs-bom,utf-8,default,latin1

Should I create a minimal init.vim/vimrc to try to force them both to the same settings?

@clason
Copy link
Member

clason commented Sep 5, 2021

nvim -u NONE skips all plugins, even the builtin ones; if you want to have a guaranteed "factory defaults" Neovim, you have to use a minimal init.vim where you set runtimepath=$VIMRUNTIME and set packpath= to skip any plugins or packages you might have in your local config.

So, yes, a minimal init.vim would be good.

@jghauser
Copy link
Author

jghauser commented Sep 5, 2021

Ok, I created such a init.vim and used it as the config for both vim and nvim. There are still some differences, but only very few. If I start vim with vim -u DEFAULTS, the differences are quite a bit more substantial (as you can see above). Let me know if I should narrow them down even further.

nvim:

--- Options ---
  columns=106         filetype=text       helplang=en         packpath=           syntax=text
  commentstring=      foldmethod=marker   lines=58            scroll=28           window=57
  comments=fb:-,fb:*,n:>
  fileencoding=utf-8

vim (with -u init.vim):

--- Options ---
  foldmethod=marker   packpath=           ttyfast
  helplang=en         scroll=28           ttymouse=xterm
  fileencoding=utf-8
  fileencodings=ucs-bom,utf-8,default,latin1

The bug still occurs in the exact same fashion in both vim and nevoim.

@luukvbaal
Copy link
Contributor

luukvbaal commented Feb 14, 2023

So was a vim issue ever opened for this? My initial (reverted) commit in #22242 would fix this.

@jghauser
Copy link
Author

I never opened an issue on vim, not sure if anyone else did.

luukvbaal added a commit to luukvbaal/neovim that referenced this issue Feb 18, 2023
… fold

Problem:    "gj" and "gk" do not move correctly over a closed fold.
Solution:   Use the same code as used for "j"/"k" to go to the next/previous
            line. (Luuk van Baal, closes vim/vim#12007)

vim/vim@441a7a9

Fix neovim#15490
@zeertzjq zeertzjq removed the needs:vim-patch upstream issue that must be fixed in Vim first label Feb 19, 2023
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug-vim wrong behavior inherited from vim folds
Projects
None yet
Development

Successfully merging a pull request may close this issue.

6 participants