Morantron / tmux-fingers

copy pasting in terminal with vimium/vimperator like hints.
MIT License
1k stars 46 forks source link

Too many matches is an unhandled exception #112

Closed knpwrs closed 9 months ago

knpwrs commented 9 months ago

Tmux fingers isn't working for me in a particular pane. The log contains the following:

Unhandled exception: Too many matches (Exception)
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
  from /opt/homebrew/Cellar/tmux-fingers/2.1.1/bin/tmux-fingers in '??'
Morantron commented 9 months ago

Can you share the contents of the pane? Would help reproduce the issue.

knpwrs commented 9 months ago

I actually can't reproduce right now, even with the following node script:

for (let i = 0; i < 1000; i++) {
  for (let j = 0; j < 10; j++) {
    process.stdout.write(`/${i}/${j} `);
  }
}

Which spams the console thusly:

image

And fingers still works:

image

I'll close this issue for now and if it happens again I'll grab the buffer contents.

NeilHanlon commented 9 months ago

I've encountered this trying to use fingers, myself, even with an empty (new) buffer.

Unhandled exception: Regex match error: match limit exceeded (Regex::Error)
  from /usr/share/crystal/src/regex/pcre2.cr:272:12 in 'match_data'
  from /usr/share/crystal/src/regex/pcre2.cr:206:18 in 'match_impl'
  from /usr/share/crystal/src/regex.cr:614:12 in 'match_at_byte_index'
  from /usr/share/crystal/src/string.cr:4746:19 in 'count_unique_matches'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:187:22 in 'n_matches'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:101:68 in 'regenerate_hints!'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:95:7 in 'hints'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:145:14 in 'pop_hint!'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:138:16 in 'hint_for_text'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:117:14 in 'replace'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:80:42 in 'process_line'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:51:52 in 'run'
  from .tmux/plugins/tmux-fingers/src/fingers/view.cr:31:7 in 'render'
  from .tmux/plugins/tmux-fingers/src/fingers/commands/start.cr:70:7 in 'show_hints'
  from .tmux/plugins/tmux-fingers/src/fingers/commands/start.cr:32:7 in 'run'
  from .tmux/plugins/tmux-fingers/src/fingers/cli.cr:21:7 in 'run'
  from .tmux/plugins/tmux-fingers/src/fingers.cr:8:3 in '__crystal_main'
  from /usr/share/crystal/src/crystal/main.cr:129:5 in 'main_user_code'
  from /usr/share/crystal/src/crystal/main.cr:115:7 in 'main'
  from /usr/share/crystal/src/crystal/main.cr:141:3 in 'main'
  from /lib64/libc.so.6 in '??'
  from /lib64/libc.so.6 in '__libc_start_main'
  from /home/neil/.tmux/plugins/tmux-fingers/bin/tmux-fingers in '_start'
  from ???
Morantron commented 9 months ago

I've encountered this trying to use fingers, myself, even with an empty (new) buffer.

Unhandled exception: Regex match error: match limit exceeded (Regex::Error)
  from /usr/share/crystal/src/regex/pcre2.cr:272:12 in 'match_data'
  from /usr/share/crystal/src/regex/pcre2.cr:206:18 in 'match_impl'
  from /usr/share/crystal/src/regex.cr:614:12 in 'match_at_byte_index'
  from /usr/share/crystal/src/string.cr:4746:19 in 'count_unique_matches'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:187:22 in 'n_matches'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:101:68 in 'regenerate_hints!'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:95:7 in 'hints'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:145:14 in 'pop_hint!'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:138:16 in 'hint_for_text'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:117:14 in 'replace'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:80:42 in 'process_line'
  from .tmux/plugins/tmux-fingers/src/fingers/hinter.cr:51:52 in 'run'
  from .tmux/plugins/tmux-fingers/src/fingers/view.cr:31:7 in 'render'
  from .tmux/plugins/tmux-fingers/src/fingers/commands/start.cr:70:7 in 'show_hints'
  from .tmux/plugins/tmux-fingers/src/fingers/commands/start.cr:32:7 in 'run'
  from .tmux/plugins/tmux-fingers/src/fingers/cli.cr:21:7 in 'run'
  from .tmux/plugins/tmux-fingers/src/fingers.cr:8:3 in '__crystal_main'
  from /usr/share/crystal/src/crystal/main.cr:129:5 in 'main_user_code'
  from /usr/share/crystal/src/crystal/main.cr:115:7 in 'main'
  from /usr/share/crystal/src/crystal/main.cr:141:3 in 'main'
  from /lib64/libc.so.6 in '??'
  from /lib64/libc.so.6 in '__libc_start_main'
  from /home/neil/.tmux/plugins/tmux-fingers/bin/tmux-fingers in '_start'
  from ???

I'm not 100% sure if this is the same issue or not: this exception seems to come from the regexp engine itself, while the "Too many matches" one is an application error.

Do you have any custom patterns in your ~/.tmux.conf file @NeilHanlon ? 🤔

NeilHanlon commented 9 months ago

Yeah, I noticed that too after filing the issue. I can open a new issue, if that is preferable.

No custom patterns are in my .tmux.conf - https://gist.github.com/NeilHanlon/93340c7cc0a9433f9af3d64d359715df

Morantron commented 9 months ago

Finally could reproduce it! Should be fixed now. It happened in some circumstances when re-rendering after a keystroke.