I'm on 1.33, how do I test this? Don't see any new commands with "namespace" in them.

    5 days later

    JakubMisek

    Pressing ctrl + . while my cusor was on Request had no effect for me, nothing pops up.
    Can we define our own keyboard shortcut?

    (And I can't seem to attach images here... ctrl+v doesn't convert into a URL like normal and it brings me back to the previous conversation on this forum)

      phptools

      I think it's a different shortcut on Mac/Linux. Do you see a lightbulb if you place a cursor on Request?

      Keyboard mapping can be changed in VSCode, the command is called "Quick Fix".

      9 days later

      Yes, I see a light bulb.

      I'm on code server actually, I suppose that is Linux? I checked and found multiple definitions for ctrl + . by default.


        JakubMisek I don't think "Quick Fix" is suitable. My monitor is 1440 px in height at 100%, the list is too long to fit and there is no scrolling capability. I think switching to the ctrl + p style is more suitable 🙏

          phptools I see!

          I agree. A command would make more sense in this case, and in case of anyone having so many classes.

            phptools That would make more sense in case of more options, thank you for the tip!

              11 days later

              We've implemented "Import class ..." command (id: "phptools.importClass"). As suggested above, it gets a list of possible fixes as a drop-down quick-pick:

              The feature is available in the latest pre-release.

              I'm wondering if it would be useful to implement any other import commands?

                JakubMisek hi thanks

                1. Ok, phptools.importClass works for me! Thank you!
                2. What do you mean by other import commands? Give me an example to think about?

                2 suggestions:

                1. If my code is \Illuminate\Support\Facades\App::blah(...) and I run phptools.importClass, it should still show me a list based on App because I might have selected a wrong namespace previously. Currently, a No classes found toast appears instead of the UI, I suppose it is because it cannot find alternatives to \Illuminate\Support\Facades\App.

                2. Separate inline Illuminate\Support\Facades\App and use Illuminate\Support\Facades\App into 2 commands or make it configurable not to show the inline one. The cognitive load required to pick from a long list is quite significant and for readability, we seldom inline classnames. I usually see inline classnames only when there is a clash. Offhand, I'm thinking ctrl + alt + i for use, ctrl + alt + shift + i for inline. The command name can be phptools.inlineClass haha

                phptools the idea was to start typing a few letters (i.e. us Fac), so the long list gets filtered. But I see the point.

                  JakubMisek

                  Can't speak for the rest, but for Laravel where classes frequently have the same class name due to convention, normally I look for the line with the word Facade and pick that. However, now I have to choose between 2 Facade, inline vs use, that is what I meant by the cognitive load.

                  But I can see why it is a good idea, sometimes when we want to include traits (which starts with use), Let me use it a bit more, but meanwhile, would be great if I can disable use through a setting. 😉

                  Thank you!

                    phptools Makes sense, thank you for testing it! We'll be improving it over time.

                      JakubMisek

                      I suppose I'm the only one testing it?

                      Possible to disable inline for time being as it is harder to use than the one I was relying on before.

                      In other words, I would like only use XXXX to show, i.e. it will insert under use XXXX statements after namespace ...

                      Thank you.

                        phptools I'm not sure I understand this one:)

                        In the new quick pick command, there are both use ... and FQN \..., so it's easy to just hit a few letters and hit enter or arrow down and enter.