Shougo / pum.vim

Original popup completion menu framework library
MIT License
110 stars 19 forks source link

Executing `pum#map#cancel` after `pum#map#insert_relative` breaks input text for some ddc sources #31

Closed azufr closed 2 years ago

azufr commented 2 years ago

Warning: I will close the issue without the minimal init.vim and the reproduction instructions.

Problems summary

Thank you for creating many great plugins. When executing pum#map#cancel after pum#map#insert_relative, the inserted text does not revert to original input text. This weird behaviour only happens for some ddc sources(nvim-lsp, and vsnip at the moment) and does not happen in around source.

Expected

Executing pum#map#cancel should revert the inserted text to the original input text.

Environment Information (Required!)

NVIM v0.8.1
Build type: Release
LuaJIT 2.1.0-beta3
Compiled by builduser

Features: +acl +iconv +tui
See ":help feature-compile"

   system vimrc file: "$VIM/sysinit.vim"
  fall-back for $VIM: "/usr/share/nvim"

Run :checkhealth for more info

Provide a minimal init.vim/vimrc without plugin managers (Required!)

" Your minimal init.lua
vim.opt.runtimepath:append({ '~/.dein/repos/github.com/vim-denops/denops.vim' })
vim.opt.runtimepath:append({ '~/.dein/repos/github.com/Shougo/ddc.vim' })
vim.opt.runtimepath:append({ '~/.dein/repos/github.com/Shougo/ddc-around' })
vim.opt.runtimepath:append({ '~/.dein/repos/github.com/tani/ddc-fuzzy' })
vim.opt.runtimepath:append({ '~/.dein/repos/github.com/hrsh7th/vim-vsnip' })
vim.opt.runtimepath:append({ '~/.dein/repos/github.com/hrsh7th/vim-vsnip-integ' })
vim.opt.runtimepath:append({ '~/.dein/repos/github.com/rafamadriz/friendly-snippets' })
vim.opt.runtimepath:append({ '~/.dein/repos/github.com/Shougo/ddc-ui-pum' })
vim.opt.runtimepath:append({ '~/.dein/repos/github.com/Shougo/pum.vim' })

vim.opt.completeopt = { 'menu', 'menuone', 'noinsert' }
vim.fn['pum#set_option']('use_complete', false)
vim.fn['pum#set_option']('scrollbar_char', '')
local ddc_opts = {
    ui = 'pum',
    autoCompleteEvents = { 'InsertEnter', 'TextChangedI', 'TextChangedP', 'CmdlineChanged', 'CmdlineEnter' },
    sources = { 'around', 'vsnip' },
    sourceOptions = {
        _ = {
            matchers = { 'matcher_fuzzy' },
            sorters = { 'sorter_fuzzy' }
        },
        ['vsnip'] = {
            mark = "[vs]",
            dup = 'keep',
            ignoreCase = true,
        },
        ['around'] = {
            mark = '[A]'
        }
    }
}

vim.fn['ddc#custom#patch_global'](ddc_opts)
vim.fn['ddc#enable']()

vim.cmd([[autocmd User PumCompleteDone call vsnip_integ#on_complete_done(g:pum#completed_item)]])

vim.keymap.set('i', '<C-y>', '<cmd>call pum#map#confirm()<cr>')
vim.keymap.set('i', '<C-e>', '<cmd>call pum#map#cancel()<cr>')
vim.keymap.set('i', '<C-n>', '<cmd>call pum#map#insert_relative(+1)<cr>')
vim.keymap.set('i', '<C-p>', '<cmd>call pum#map#insert_relative(-1)<cr>')

How to reproduce the problem from neovim/Vim startup (Required!)

  1. Save above settings to min_init.lua
  2. Start neovim and edit python file (I think it should be reproduced with other filetypes too)
      nvim -Nu min_init.lua test.py
  3. Please refer to screencast for detail

Screen shot (if possible)

Unexpected Behaviour (pum#cancel on vsnip source entry)

unexpected_behaviour

Expected Behaviour (pum#cancel on around source entry)

expected_behaviour

Upload the log messages by :redir and :message (if errored)

No error messages.

Shougo commented 2 years ago

Fixed.

azufr commented 2 years ago

Can confirm it is fixed. Thanks.