haya14busa / incsearch.vim

:flashlight: Improved incremental searching for Vim
https://medium.com/@haya14busa/incsearch-vim-is-dead-long-live-incsearch-2b7070d55250
MIT License
1.11k stars 23 forks source link

missing keys if typed fast #130

Open HenryHu opened 7 years ago

HenryHu commented 7 years ago

When using incsearch in a large file and I type fast, some keys are missing. If I type slowly, all the keys are there. It seems like that the plugin causes vim to lag behind and miss keys. The internal incsearch feature does not have this problem.

haya14busa commented 7 years ago

Can you give me detail reproduction steps or something useful to debug this issue?

You can use :profile command too.

HenryHu commented 7 years ago

I can't share the file to you, but I can show you how to reproduce it:

  1. open a big file, here the file is 23M with 196K lines.
  2. search for something, type fast. You would see keys are missing from the searching prompt when the prompt gets longer (usually >10 chars), but it also appears sometime when the prompt only has 6 chars. I tried the profile command by typing :profile start profile.txt, do the search, see the missing keys, and exit, but the profile.txt is empty. It seems like that if you type the next character before the current character finishes processing, the next character may lost.
haya14busa commented 7 years ago

profile.txt cannot be empty. maybe you didn't stop profiling or something. See :h profile

HenryHu commented 7 years ago

okay, I missed :profile file and profile func The profile log is at http://chopapp.com/#wpyokmkm

haya14busa commented 7 years ago

can you upload the file to gist? it's too slow to see.

HenryHu commented 7 years ago

https://gist.github.com/HenryHu/ddd7389d926d4030a4bd20b751f7064d

ntkme commented 7 years ago

This can be easily reproduced by pasting from system clipboard into vim in a terminal emulator. Once incsearch is activated, hitting CMD-V on OS X only inserts the first character in system clipboard.

haya14busa commented 7 years ago

Thanks. so the problem might be here

https://gist.github.com/HenryHu/ddd7389d926d4030a4bd20b751f7064d#file-profile-txt-L11613

FUNCTION  <SNR>103__execute_search()
Called 32 times
Total time:   1.218723
 Self time:   1.218723

count  total (s)   self (s)
                              " :nohlsearch
                              "   Please do not highlight at the first place if you set back
                              "   info! I'll handle it myself :h function-search-undo
   31              1.125498   execute s:keeppattern 'keepjumps' 'normal!' a:cmd | nohlsearch

It executes builtin search command. I'm not sure but search command itself could be slow on large file.

haya14busa commented 7 years ago

hitting CMD-V on OS X only inserts the first character in system clipboard.

Do you use incsearch.vim at the latest version??? it won't happen in linux.

ntkme commented 7 years ago

@haya14busa I found out that this issue can be reliably reproduced on vim 8.0-p512 by either pasting or typing really fast, while the system provided vim 7.4-p898 works just fine.

haya14busa commented 7 years ago

Thank!

https://github.com/vim/vim/commit/1572e30607e9a3bee9750242bf37168f7d2b6e66 (vim 8.0-p512) seems it might be related with this issue. Do you test it with the patch?

I tested on latest in linux but I cannot reproduce it.

HenryHu commented 7 years ago

I'm using vim 8.0.0427 on ArchLinux. If you think that the patch 512 fixes the issue, I would test after arch updates its package.

ntkme commented 7 years ago

Patch 512 did not fix the problem as I have stated above. Since @HenryHu is using ArchLinux and I'm using OS X, I think this issue is also OS independent.

I will do a bisect later to find out the exact version of vim that introduced this issue.

haya14busa commented 7 years ago

I will do a bisect later to find out the exact version of vim that introduced this issue.

Thanks!

ntkme commented 7 years ago

@haya14busa I could not isolate @HenryHu's issue with any specific version of vim. Now I think pasting and typing fast are actually two different problems, so I have opened #131.