farmergreg / vim-lastplace

A vim / nvim plugin that intelligently reopens files at your last edit position.
https://www.gregd.org/
MIT License
583 stars 28 forks source link

Error on large files #33

Closed Huluk closed 6 months ago

Huluk commented 6 months ago

Error detected while processing function <SNR>153_lastplace_open_folds: E363: pattern uses more memory than 'maxmempattern

Maybe the regex can be fixed to be more efficient – otherwise maybe disable the plugin on larger files (by flag?).

farmergreg commented 6 months ago

@Huluk thanks for the bug report!

Thanks!

Huluk commented 6 months ago

Hi Greg, and thank you for the quick reply!

The file I ran into problems with has ~16k lines and about 3.5MB. I'm using all-default settings.

farmergreg commented 6 months ago

I tried and failed to to reproduce this issue by creating a ~4mb file with this command: head -n 68000 /dev/urandom | tr -dc 'a-zA-Z0-9' | fold -w 100 > 4mb.txt . The generated file works well with vim-lastplace. I also tried with longer lines using fold -w 1000000. Same result, unable to reproduce.

Since the error mentions increasing mmp, you might try setting this in your vimrc: set maxmempattern=32000 for more info on that, please take a look at the vim help :h mmp

I'll be curious to know if changing this setting helps you out!

Huluk commented 6 months ago

I can confirm this issue does not happen for a random file like yours, so I did some digging: Turns out the inbuilt setting foldmethod=syntax was at fault here, eating most of the memory. The error triggering in your plugin is spurious. I had tried to disable all other plugins, but I hadn't disabled all other settings.

Thank you for your investigation! I'll close this bug.