adrhumphreys / vscode-silverstripe

Basic template syntax highlighting for Silver Stripe template files.
https://marketplace.visualstudio.com/items?itemName=adrianhumphreys.silverstripe
MIT License
5 stars 12 forks source link

Poor Intellisense performance in project with SilverStripe CMS requirement #17

Closed kgiglia closed 4 years ago

kgiglia commented 4 years ago

I've been having on-and-off bad performance with Intellisense in PHP for the past few days, and seem to have tracked it down to only occurring when I have this module enabled, and a specific folder open (either on its own, or as part of a workspace).

In the composer.json for that folder:

{
    ...
    "type": "silverstripe-vendormodule",
    "require": {
        "silverstripe/cms": "^4.0"
    },
    ...
}

When I've got this folder open, it takes a few seconds for the Intellisense list to be populated, and if I close the folder, or roll this module back to 0.0.5, it seems to be working normally.

This doesn't appear to be happening when working in a proper SilverStripe project, i.e. no type key in the composer.json.

Any idea why this could be happening?

gorriecoe commented 4 years ago

So just to clarify is it only happening while you are developing a SS module?

kgiglia commented 4 years ago

That seems to be the case, though even from module to module performance seems to vary a fair bit. The context where it seems to be struggling the most is while adding code to a private function in a class extending SilverStripe\Control\Controller, but I'm not quite sure what differentiates one controller from another in the same project where the problem isn't quite as pronounced.

kgiglia commented 4 years ago

It could be tied to the length of the class being edited, trying to edit something like this for example causes Intellisense to hang for nearly a full minute when I hit ctrl+space on an empty line.

gorriecoe commented 4 years ago

Hmm could be tied to the php parser then. Its used to inject use item namespaces. If you follow the instructions here: https://github.com/gorriecoe/silverstripe-sanchez#custom-settings-and-snippets to disable use items does that make a difference?

kgiglia commented 4 years ago

Yeah, with that disabled it appears to be performing normally.

I also noticed Intellisense isn't always being populated with the SilverStripe snippets, e.g. the Intellisense dropdown that appears after typing $this-> only has the normal php suggestions, but hitting esc and then ctrl+space shows snippets as well.

gorriecoe commented 4 years ago

Ok so I think I can improve the performance. VsCode is probably running the php parser multiple times for each snippet at this point. I'll move the this function https://github.com/adrhumphreys/vscode-silverstripe/blob/master/src/silverstripeCompletionProvider.ts#L38-L51 to after snippet itself is injected.

gorriecoe commented 4 years ago

Alrighty, I have started off by moving that function as mentioned above. https://github.com/adrhumphreys/vscode-silverstripe/commit/c6a00f54f34276859f33fb79de181ba841cb0636. Hopefully this will help as it should only run the php-parser once the snippet is selected.

As for the $this-> are you able to give me a screenshot or something. I found this really helpful when debugging. https://github.com/adrhumphreys/vscode-silverstripe/issues/13#issuecomment-658901046

kgiglia commented 4 years ago

Thanks for that!

Here's what I see at the moment with $this->: intellisense The second pop-up is triggered by ctrl+space.

gorriecoe commented 4 years ago

I think that is a setting isn't it. For me ctrl + space triggers a detailed description of auto completes. autocomplete

gorriecoe commented 4 years ago

Are you able to check your key bindings? =)

kgiglia commented 4 years ago

Sorry if that clip's a bit confusing - the initial suggestion box pops up on its own once I stop typing (I think this is controlled by the editor.quickSuggestions and editor.quickSuggestionsDelay preferences), then I'm hitting esc to dismiss it, then ctrl+space to bring it up again. I'm only seeing the SS snippets once bringing it up manually.

I haven't changed the default keybindings for ctrl+space: Screenshot from 2020-07-23 10-50-56

gorriecoe commented 4 years ago

Ok I'm not able to replicate this issue. What I'll do is get @adrhumphreys to publish an update. Then I you are happy with the performance get you to sign off on that and create a new issue for the ctrl + space.

kgiglia commented 4 years ago

That sounds good to me. Thanks again for this fix!

gorriecoe commented 4 years ago

1.0.5 has been published. Let me know if this helps?

kgiglia commented 4 years ago

Seems to be much better. I also got a couple coworkers that were able to recreate the issue to test 1.0.5 and it looks good.

gorriecoe commented 4 years ago

Awesome!