vim-matchup icon indicating copy to clipboard operation
vim-matchup copied to clipboard

Feature: Option to set motion timeouts

Open MCredstoner2004 opened this issue 2 years ago • 5 comments
trafficstars

Is your feature request related to a problem? Please describe. I'm working on a large C++ file, with a lot of characters, and after some point, [% and ]% stop working, they always reach the hardcoded timeout of 750ms and give up, MatchupWhereAmI also has similar issues btw (both use the find_unmatched function).

Describe the solution you'd like It'd be nice to be able to change these hardcoded timeouts through an option, for when you know you're working on large files and don't mind waiting a few seconds for the cursor to move.

Describe alternatives you've considered I also noticed that, ironically, highlighting the matching bracket was faster than going to it, this seems to be due to it using the treesitter backend, so, idk if it's possible, but maybe it'd help implementing a treesitter based find_unmatched function, which would probably help with the runtime.

Additional context I tested manually calling the functions with the longer time outs, and they do properly go to the desired bracket, but often take several seconds (which I wouldn't normally mind given how useful they are).

MCredstoner2004 avatar Jul 10 '23 07:07 MCredstoner2004

Can you share the C++ file in question, or at least one having the issue?

I agree optimizing find_unmatched using more TS features is needed at this point. Adjusting timeouts is fine but it's better if we can return the result quickly.

andymass avatar Jul 10 '23 23:07 andymass

Another thing that we can try is if this suggestion changes the performance: https://github.com/andymass/vim-matchup/issues/302#issue-1788729100

If so, then it may be isolated to that specific functionality.

andymass avatar Jul 10 '23 23:07 andymass

Can you share the C++ file in question, or at least one having the issue?

Yeah, I wasn't working with a file this big when I made the feature request, but since I've tested this issue on my desktop instead of my laptop, and to be able to reproduce it I had to create a much larger file main.cpp.zip (the file was generated by replacing a deduced type with a fully deduced one in an expression tree like matrix library I'm working of as a side project, it wouldn't be expected for anyone to write a type that specific, but that's the easiest quickest way I found of generating valid C++ code.) If you set the cursor at line 3881 find_unmatched should go well over timeout on almost any device and as a result you can't do [%, however, if I out the cursor on the next line (3882) I immediately get the popup showing the matching namespace opening, and can jump to it just fine with %. Due to the number of lines in the file, I increased the stopline variables to over 9000, and even on my laptop, I still get the popup with the matching bracket almost instantly. MatchuShowTimes

MCredstoner2004 avatar Jul 11 '23 07:07 MCredstoner2004

Interestingly I can't seem to reproduce this.

From line 3381 [% goes to line 3147 due to the < in under 200ms

From line 3382 [% goes to line 3381 again on the < in under 50ms.

Could I be missing anything config-wise?

andymass avatar Jul 11 '23 14:07 andymass

Ah sorry, I just can't type, it was 3881 and 3882, I'll update the previous comment just so the reproduction steps should be all there, as for config, I only configured the aforementioned stopline variables, and enabled the treesitter backend.

MCredstoner2004 avatar Jul 11 '23 16:07 MCredstoner2004