tpope / vim-unimpaired

unimpaired.vim: Pairs of handy bracket mappings
https://www.vim.org/scripts/script.php?script_id=1590
3.33k stars 203 forks source link

Slow performance when "+[p #236

Open ColinKennedy opened 7 months ago

ColinKennedy commented 7 months ago

When I use [p, it is fast. But if I get from the "+ register, [p and ]p are slow.

OS: Windows 10 Terminal: Wezterm Shell: WSL (Ubuntu 20.02) Neovim version:

:version
NVIM v0.10.0-dev-2791+g99b3a068d
Build type: RelWithDebInfo
LuaJIT 2.1.1710088188
nvim -u reproduction.lua ```lua -- DO NOT change the paths and don't remove the colorscheme local root = vim.fn.fnamemodify("./.repro", ":p") -- set stdpaths to use .repro for _, name in ipairs({ "config", "data", "state", "cache" }) do vim.env[("XDG_%s_HOME"):format(name:upper())] = root .. "/" .. name end -- bootstrap lazy local lazypath = root .. "/plugins/lazy.nvim" if not vim.loop.fs_stat(lazypath) then vim.fn.system({ "git", "clone", "--filter=blob:none", "https://github.com/folke/lazy.nvim.git", lazypath, }) end vim.opt.runtimepath:prepend(lazypath) -- install plugins local plugins = { -- Adds pair mappings (like ]l [l) to Vim { "tpope/vim-unimpaired", version = "2.*", }, } require("lazy").setup(plugins, { root = root .. "/plugins", }) vim.cmd[[set laststatus=3]] ```

If you copy it to a different register and paste, it's normal speed (fast)

I did a profile file * | profile func * and 0.5 seconds are devoted to this chunk of code

FUNCTION  <SNR>69_putline()
    Defined: ~/repositories/personal/.config/nvim/bundle/vim-unimpaired/plugin/unimpaired.vim:408
Called 1 time
Total time:   0.568220
 Self time:   0.567142

count  total (s)   self (s)
    1              0.376446   let [body, type] = [getreg(v:register), getregtype(v:register)]
    1              0.000007   if type ==# 'V'
    1   0.191621   0.190604     exe 'normal! "'.v:register.a:how
                              else
                                call setreg(v:register, body, 'l')
                                exe 'normal! "'.v:register.a:how
                                call setreg(v:register, body, type)
    1              0.000002   endif
    1   0.000111   0.000050   silent! call repeat#set("\<Plug>(unimpaired-put-".a:map.")")
justinmk commented 6 months ago

Nvim clipboard performance (the "+ register) depends on how you have defined g:clipboard. It's common for that to involve powershell in WSL.

ColinKennedy commented 6 months ago

I'm using Wezterm + cmd, should I switch to a different terminal / shell?