machakann / vim-highlightedyank

Make the yanked region apparent!
844 stars 22 forks source link

UI blocked when trying to yank a big file in vim #24

Closed KabbAmine closed 6 years ago

KabbAmine commented 6 years ago

I had to yank a big dictionary files (One with more than 600000 lines) and both vim and gvim froze for a long time (C-c didn't work). Using a text-object (ie in my config) or a visual selection with a minimal vimrc makes no difference (Using :norm! ggVGy or 1,$y is instantaneous as expected).

To reproduce it, set spelllang and spell in vim then list the spell words with spelldump in a new window and try to yank them.

IMHO you may add an option for disabling highlighting on a certain limit of linewise-visual selected lines or add a workaround in the documentation (e.g. map <silent> <expr> y line('$') <# 10000 ? "<Plug>(highlightedyank)" : "y").

machakann commented 6 years ago

I wasn't aware of this but, indeed, this is not so happy. Probably highlightedyank should give up highlighting with too much lines or just timeout (~1s?).

KabbAmine commented 6 years ago

Probably highlightedyank should give up highlighting with too much lines or just timeout (~1s?).

Both options are viable and can be implemented together (~2s is more reasonable IMO~).

KabbAmine commented 6 years ago

I've just tested the develop branch and using the timer only is not so nice, the 1 second delay freezing is noticeable. Its better to relay on the number of lines 1st, then set the timer as a 2nd option.

Also note that the echoed message will be instantly overwritten by the message XXXX lines yanked, so either use echomsg to keep it in the history or do not show it and document this behaviour in the documentation.

machakann commented 6 years ago

Fair enough, I will add the other safety. What do you think about the default giving-up line number? 10000 would be reasonable?

As for the message, I will remove it probably. Just put explanations in documents. I think it is enough.

I didn't know that a commit in a not-master branch is also noticed here. I was not confident of it, but I am happy that I got feedback. Thanks!

KabbAmine commented 6 years ago

Yes its enough, 10000 long lines are yanked without a noticeable delay.

Thanks to you for your work, your plugins make my life easier :smile:

machakann commented 6 years ago

I updated. The option names are g:highlightedyank_max_lines and g:highlightedyank_timeout now.

KabbAmine commented 6 years ago

:+1:

The issue can be closed after merging to master.

machakann commented 6 years ago

Merged. Thank you!

machakann commented 6 years ago

JUST A NOTE:

After a long test period, I found the g:highlightedyank_max_lines is quite useful for my experience, however, g:highlightedyank_timeout could hardly be useful. Probably g:highlightedyank_max_lines is effective all the time even with a poor computer.

Another problem is that the option name g:highlightedyank_timeout is somehow easily misunderstood with g:highlightedyank_highlight_duration.

I feel a little sentimental, but I will deprecate g:highlightedyank_timeout option near future. I think it would be less confusing for new users.