ChristianKohler / PathIntellisense

Visual Studio Code plugin that autocompletes filenames
https://marketplace.visualstudio.com/items?itemName=christian-kohler.path-intellisense
MIT License
424 stars 45 forks source link

Relative paths no longer working #196

Closed spfuller closed 2 years ago

spfuller commented 2 years ago

My paths are no longer relative to my current folder since either the 2.6.1 or 2.7.0 update.

I used to be able to do './' and the suggestion would be from my current folder. However it now always suggests from the workspace root folder. All of my settings are default.

ChristianKohler commented 2 years ago

Thank you @spfuller

What is your OS? How does your extension config look like?

AliaksanauRaman commented 2 years ago

Same from my side. My OS is MacOS Big Sur 11.6.

I work with my angular project. I didn't add any specific configurations. I have only the ones which were there by default after executing ng new my-app.

spfuller commented 2 years ago

Iā€™m using windows and the configuration is the defaults for PathIntellisense.


From: Christian Kohler @.***> Sent: Saturday, January 29, 2022 03:13 To: ChristianKohler/PathIntellisense Cc: Simon Fuller; Mention Subject: Re: [ChristianKohler/PathIntellisense] Relative paths no longer working (Issue #196)

Thank you @spfullerhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fspfuller&data=04%7C01%7C%7C247469dec4ea413e39dd08d9e2791e4b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637789832103721681%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=xzbSiLpWCEJ4VoRX1bZ6WvxbsEbuaCcCCozoDBC5VRE%3D&reserved=0

What is your OS? How does your extension config look like?

ā€” Reply to this email directly, view it on GitHubhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2FChristianKohler%2FPathIntellisense%2Fissues%2F196%23issuecomment-1024368243&data=04%7C01%7C%7C247469dec4ea413e39dd08d9e2791e4b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637789832103721681%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=kqAgEeftHuY7hzVqiUCTqpvNJgqJHMhOLDwAHyt9G9A%3D&reserved=0, or unsubscribehttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fgithub.com%2Fnotifications%2Funsubscribe-auth%2FAHY4TCV3QE6D3CLGICLABL3UYK6CPANCNFSM5M7W4QZA&data=04%7C01%7C%7C247469dec4ea413e39dd08d9e2791e4b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637789832103721681%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=BbkLwdgxiFo1WcTN5Oo1COuJo7eylIfeGDd9jAdqxss%3D&reserved=0. Triage notifications on the go with GitHub Mobile for iOShttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fapps.apple.com%2Fapp%2Fapple-store%2Fid1477376905%3Fct%3Dnotification-email%26mt%3D8%26pt%3D524675&data=04%7C01%7C%7C247469dec4ea413e39dd08d9e2791e4b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637789832103721681%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=BgNBVugp%2FAxZd3IM5ioXJCyfRO25VjvGXRh9XamB0uU%3D&reserved=0 or Androidhttps://emea01.safelinks.protection.outlook.com/?url=https%3A%2F%2Fplay.google.com%2Fstore%2Fapps%2Fdetails%3Fid%3Dcom.github.android%26referrer%3Dutm_campaign%253Dnotification-email%2526utm_medium%253Demail%2526utm_source%253Dgithub&data=04%7C01%7C%7C247469dec4ea413e39dd08d9e2791e4b%7C84df9e7fe9f640afb435aaaaaaaaaaaa%7C1%7C0%7C637789832103721681%7CUnknown%7CTWFpbGZsb3d8eyJWIjoiMC4wLjAwMDAiLCJQIjoiV2luMzIiLCJBTiI6Ik1haWwiLCJXVCI6Mn0%3D%7C3000&sdata=4nDdgzWdRqpc0c2tTjD9piOsnlXsps6%2BxAvQvTWH4VY%3D&reserved=0. You are receiving this because you were mentioned.Message ID: @.***>

AliaksanauRaman commented 2 years ago

The funny thing is that I've tried almost all of the 2.x.x versions and non of them worked. Only 1.4.2 (the latest version before the major change) works fine for me.

@spfuller you can also try to use this one for now.

ChristianKohler commented 2 years ago

Thank you for the feedback.

I just tried to reproduce it. In this case i get the current folder and not the root:

https://user-images.githubusercontent.com/4374178/151701066-b0833023-f085-4150-9e33-340521d9f403.mov

In this case, it gives you the root folder instead of the current folder. Right?

Could you provide a small example with which I can reproduce it?

AliaksanauRaman commented 2 years ago
Screenshot 2022-01-30 at 14 18 09 Screenshot 2022-01-30 at 14 18 30

The first screenshot is taken with the extension of version 1.4.2 (everything works as expected). The second one is taken with the extension of version 2.7.0 (the root folder of the workspace is shown).

ChristianKohler commented 2 years ago

Ok. I found the issue.

Analysis

By default, PathIntellisense reads the baseUrl in the tsconfig.

For example, if the tsconfig looks like this:

 {
    "baseUrl": "src",
 }

"src" would we used as a key to ${workspace}/src

 {
    import {} from 'src/mymodule';
 }

With Angular, the baseUrl is set to:

 {
    "baseUrl": "./",
 }

which means that the "key" is ./ which would then be resolved to ${workspace}/./

The root of the problem is my over simplified solution to how I resolve the baseurl. I only add the baseurl to the mapping list like this:

 {
    key: "src",
        value: "${workspaceRoot}/src"
 }

Now when you type "src/", the mapping resolved to "${workspaceRoot}/src" showing you all the children of src.

That approach works with all baseUrls, except ./ (afaik).

Short term solution

Just disable the baseUrl support.

image

Long term solution

Not sure yet. I'd either have to rewrite the baseUrl logic to deal with ./ or just ignore it. Not sure.

Thank you all for you inputs. Hope disabling the baseUrl support work for you for now.

spfuller commented 2 years ago

Thanks, that short term solution works for me

ChristianKohler commented 2 years ago

:tada: This issue has been resolved in version 2.8.0 :tada:

The release is available on GitHub release

Your semantic-release bot :package::rocket:

ChristianKohler commented 2 years ago

Thank you for all your input. I did quite a rewrite to have proper support for base urls. Would be great if you could try it out with the new version 2.8.0 šŸ™

spfuller commented 2 years ago

Thanks so much for this release. I can confirm that the issue is fixed with this new version.