Skip to content

Conversation

@PhoebeSzmucer
Copy link
Contributor

Fixes #55232

I couldn't find where this is tested (if it even is). If someone can help me out with that I can write a test.

@typescript-bot typescript-bot added the For Uncommitted Bug PR for untriaged, rejected, closed or missing bug label Aug 1, 2023
@sandersn sandersn requested a review from sheetalkamat August 11, 2023 22:20
@sheetalkamat
Copy link
Member

You would need to add test in src/testRunner/unittests/tsserver/autoImportProvider.ts following example of one of the test case there.

@PhoebeSzmucer
Copy link
Contributor Author

You would need to add test in src/testRunner/unittests/tsserver/autoImportProvider.ts following example of one of the test case there.

Isn't that for auto-import and not path completion? Or do these go through the same code path?

@PhoebeSzmucer
Copy link
Contributor Author

I added a throw statement to getBaseDirectoriesFromRootDirs and the only test that failed was tests/cases/fourslash/completionForStringLiteralRelativeImport4.ts

@PhoebeSzmucer
Copy link
Contributor Author

@microsoft-github-policy-service agree company="Palantir"

@PhoebeSzmucer
Copy link
Contributor Author

@sheetalkamat I added a fourslash test that failed before and succeeds now

@PhoebeSzmucer
Copy link
Contributor Author

@sheetalkamat any chance this can make it to the 5.2 release?

@jakebailey
Copy link
Member

5.2 was branched off a while ago and main is now targeting 5.3; see #54298. Given this bug isn't a regression from 5.1, I wouldn't expect to see it backported unless it's causing major ecosystem pain.

Phoebe Szmucer added 2 commits September 10, 2023 19:07
// Now find a path for each potential directory that is to be merged with the one containing the script
return deduplicate<string>(
[...rootDirs.map(rootDirectory => combinePaths(rootDirectory, relativeDirectory)), scriptDirectory],
[...rootDirs.map(rootDirectory => combinePaths(rootDirectory, relativeDirectory)), scriptDirectory].map(baseDir => removeTrailingDirectorySeparator(baseDir)),
Copy link
Contributor Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I had to also add removeTrailingDirectorySeparator here because otherwise some tests got broken due to duplicated entries with mismatched trailing slashes. It's probably a good idea to return consistent results anyway.

@sheetalkamat sheetalkamat merged commit eb2d1f9 into microsoft:main Sep 11, 2023
snovader pushed a commit to EG-A-S/TypeScript that referenced this pull request Sep 23, 2023
@microsoft microsoft locked as resolved and limited conversation to collaborators Oct 22, 2025
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.

Labels

For Uncommitted Bug PR for untriaged, rejected, closed or missing bug

Projects

Archived in project

Development

Successfully merging this pull request may close these issues.

TSServer import path autocomplete reads incorrect directories when a file is not a direct child of a root directory

4 participants