Thom1729 / Sublime-JS-Custom

Customizable JavaScript syntax highlighting for Sublime Text.
MIT License
137 stars 9 forks source link

JS-Custom seems to delay the rendering of any file content #119

Closed dwhenson closed 3 years ago

dwhenson commented 3 years ago

Hi, I'm loving JS-Custom - I really love the ability to see my template literals in Sublime - Thanks so much.

One issue I have is that JS-Custom seems to delay the rendering of any file content when I open Sublime, and sometimes when I open a JS file. This can be for up to 10-15 secs. When I disable JS-Custom the pages load quickly as usual.

I have tried disabling a the couple of other JS related packages to see if they are interfering with things, but it doesn't seem to make a difference. Please let me know if there is anything I can do or information I can provide to help address this?

Thanks again.

Thom1729 commented 3 years ago

Can you post your configuration?

This could be related to https://github.com/sublimehq/Packages/issues/2829.

dwhenson commented 3 years ago

Hey thanks - sure - but could you just explain what details you are looking for? Is that the settings I am using? Apologies - I'm a bit new to all this stuff.

Thom1729 commented 3 years ago

Yeah, a copy-past of your JS Custom settings file would be perfect.

dwhenson commented 3 years ago

No problem, this is what I have:

{
    "configurations": {
        "Default": {},
        "Lit": {
            "name": "JS Custom",
            "scope": "source.js",
            "file_extensions": [
                "js"
            ],
            "custom_templates": {
                "comments": {
                    "css": "scope:source.css",
                    "html": "scope:text.html.basic"
                },
                "tags": {
                    "css": "scope:source.css",
                    "html": "scope:text.html.basic",
                    "": "scope:text.html.basic",
                }
            }
        }
    }
}

Once I've started things up it seems to be fine (e.g. swapping between projects and opening files etc) but the initial opening is very slow.

Please let me know if you need any more information.

Thom1729 commented 3 years ago

I think this is probably related to the linked issue. It sounds like there may be two issues: compiling syntaxes that use with_prototype is slow, and it may not be using the cache as expected. JS Custom's custom_templates configuration option uses with_prototype for each comment or tag template you specify, so it makes sense that your configuration would be hit pretty hard.

This seems to be something that the Sublime devs are actively looking into and I'm optimistic that at least the caching issue might be a reasonably quick fix. As far as I know, there's no way for JS Custom to work around it because the with_prototype rules are critical for correctness. If this is a big problem for your workflow (if you can't just leave Sublime running), you could probably mitigate it by reducing the number of custom template rules in your configuration.

Semi-related question— I see "": "scope:text.html.basic", under tags in your configuration. Is the intent of this to scope all template literals as HTML by default? If so, this might be an opportunity for a new configuration option to do that in a more discoverable fashion.

dwhenson commented 3 years ago

Ah, and yes, "": "scope:text.html.basic", is intended to scope all literals by default. That's actually the only template rule I need in fact (I hardly ever need the CSS stuff). Any advice on improved settings would be appreciated. I really just want HTML literals to show up by default.

dwhenson commented 3 years ago

I had a play around reducing the number custom templates. I think it does speed things up slightly if I reduce them down to one, but I'm afraid the issue is still there. If I remove them all things load quickly, but adding even one back slows things down again. If there is any thing else I can do or information I can provide please let me know. Thanks.

Thom1729 commented 3 years ago

Other than what you've already done, I think we're waiting for a fix in core. Hopefully the underlying issue should be fixed soon.

dwhenson commented 3 years ago

Hope so. It's not a deal breaker in any case. Should I close this then? (Sorry not too sure on the etiquette!!)

Thom1729 commented 3 years ago

Let's keep it open for now in case someone else has a similar issue.

Thom1729 commented 3 years ago

@dwhenson The underlying issue should be fixed in current dev builds. If you're on the dev builds, can you see if the issue is resolved?

dwhenson commented 3 years ago

Thanks for the follow up. I just updated, the issue is resolved now. My "": "scope:text.html.basic", to scope all literals as HTML by default no longer works it seems. If you have any advice how to scope by default that would be really appreciated.

Thom1729 commented 3 years ago

v4.1.0-beta.4 includes a new default custom template option:

{
    "configurations": {
        "My Config": {
            "custom_templates": {
                "default": "scope:text.html.basic"
            }
        }
    }
}

How does this work for your use case?

Thom1729 commented 3 years ago

Closing this issue because the original problem is solved.

dwhenson commented 3 years ago

Apologies. I didn't see this notification. I'm not on the beta version - I'll give that a try once you push it to package control and I've updated. But original problem is solved. Rendering is fast now!

dwhenson commented 3 years ago

Just wanted to add that the updated version works great. Super fast and the default option seems to work perfectly.