Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Disable on long lines #46

Closed
davidosomething opened this issue Mar 19, 2015 · 4 comments
Closed

Disable on long lines #46

davidosomething opened this issue Mar 19, 2015 · 4 comments

Comments

@davidosomething
Copy link

On extremely long lines, e.g. real world case background-image: url('SUPER LONG DATA-URI');, the parse_css_screen function chokes because it runs out of memory

Can you turn off exclusively on or after parts of a line that is too long (e.g. exceeds the synmaxcol built-in to vim's syntax highlighting)?

@ap ap added the enhancement label Mar 23, 2015
@ap
Copy link
Owner

ap commented Mar 23, 2015

Good idea.

@ap
Copy link
Owner

ap commented Jul 21, 2016

Well, it’s a while later, sorry, but I hope you’re still interested.

The function is called s:parse_screen by now. In it there is this line:

call substitute( join( getline('w0','w$'), "\n" ), b:css_color_pat, '\=s:create_syn_match()', 'g' )

If you change that to the following, is that enough to make vim-css-color work on files where it choked before?

call filter( range( line('w0'), line('w$') ), 'substitute( getline(v:val), b:css_color_pat, ''\=s:create_syn_match()'', ''g'' )' )

That doesn’t constrain the line length, but it processes a single line at a time instead of all the lines on screen at once, so it drastically cuts down on memory consumption. (It might make the function faster too, or it might make it slower, I can’t say. I’ll have to profile to find out.)

I hope that this is enough to make it work without limiting line lengths, because then I would have to get into bytes vs characters issues, which would essentially force me to require a very recent Vim, something I am reluctant to do. (Even requiring Vim 7 bothers me. But it is what it is.)

@ap
Copy link
Owner

ap commented Jul 28, 2016

It might make the function faster too, or it might make it slower, I can’t say. I’ll have to profile to find out.

Profiling shows it to be something like 1–3%ish slower for common workloads and 5–7%ish faster for torturous workloads. That’s boils down to “no impact” as far I’m concerned, i.e. so far so good.

@ap ap closed this as completed in d70f5fb Jul 28, 2016
@ap
Copy link
Owner

ap commented Jul 28, 2016

There you go. This does not disable the plugin on long lines, instead it parses only what’s visible on screen (plus some amount of slop). Together with #43, css-color should now work fine for files of any size. Vim’s own syntax highlighting processing bogs down much worse than css-color in any case where css-color takes noticeable time.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Projects
None yet
Development

No branches or pull requests

2 participants