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

<C-p> does not move the cursor up correctly #1892

Open
2 tasks done
mamekoro opened this issue Apr 20, 2024 · 0 comments
Open
2 tasks done

<C-p> does not move the cursor up correctly #1892

mamekoro opened this issue Apr 20, 2024 · 0 comments
Labels
bug Something isn't working

Comments

@mamekoro
Copy link

FAQ

  • I have checked the FAQ and it didn't resolve my problem.

Announcement

Minimal reproducible full config

if has('vim_starting')
  set encoding=utf-8
endif
scriptencoding utf-8

if &compatible
  set nocompatible
endif

let s:plug_dir = expand('/tmp/plugged/vim-plug')
if !filereadable(s:plug_dir .. '/plug.vim')
  execute printf('!curl -fLo %s/autoload/plug.vim --create-dirs https://raw.githubusercontent.com/junegunn/vim-plug/master/plug.vim', s:plug_dir)
end

execute 'set runtimepath+=' . s:plug_dir
call plug#begin(s:plug_dir)
Plug 'hrsh7th/nvim-cmp'
Plug 'hrsh7th/cmp-path'
Plug 'hrsh7th/vim-vsnip'
call plug#end()
PlugInstall | quit

lua << EOF
local cmp = require "cmp"
cmp.setup {
    mapping = cmp.mapping.preset.insert(),
    snippet = {
        expand = function(args)
            vim.fn["vsnip#anonymous"](args.body)
        end,
    },
    sources = cmp.config.sources {
        { name = "path" },
    },
}
EOF

Description

cmp.mapping.preset.insert() assigns cmp.select_prev_item() to <C-p>, so <C-p> should move the cursor up one position in a completion window. However, it behaves unexpectedly, as described in the "Actual behavior" section below.

Steps to reproduce

I successfully reproduced this in both my host machine (Ubuntu 22.04) and a Docker container (ubuntu:22.04).

Below is the steps to reproduce with a fresh container.
If you are testing in an already set up environment, start with step 3.

  1. docker run -it --rm ubuntu:22.04
  2. Install Neovim v0.9.5 in the container.
    apt update
    apt install -y curl ca-certificates git
    curl -LO https://github.com/neovim/neovim/releases/download/v0.9.5/nvim-linux64.tar.gz
    tar -xf nvim-linux64.tar.gz -C /usr --strip-components=1
  3. Create ~/cmp-repro.vim as above.
  4. nvim -u ~/cmp-repro.vim
  5. Press i to enter insert mode.
  6. Enter /. You'll see the path completion window.
  7. Enter ctrl-n several times to move the cursor down.
  8. Enter ctrl-p several times to move the cursor up.

Expected behavior

Each time ctrl-p is pressed, the cursor should move up one item.

Actual behavior

The first time I press ctrl-p, nothing happens.
The second time I press it, the cursor moves up two items.
Thereafter, this is repeated each time I press ctrl-p.

screencast.webm

Additional context

OS: Ubuntu 22.04
Neovim: v0.9.5

@mamekoro mamekoro added the bug Something isn't working label Apr 20, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

1 participant