You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
expected behavior is to actually return the input as specified, so the following code would be valid:
const rel = workspace.asRelativePath(testPath);
if (testPath === rel) { // do non-relative path things }
having to do a separate test for (testPath === workspace.rootPath) is not ideal, either. How is this intended to be handled for the multi-root feature? Will it still return the testPath?
Perhaps now would be a great time to make this feature more usable, and create a better function that clarifies and makes more usable the different use cases, rather than the current solution of having asRelativePath report different things depending on the project setup (yuk!) and environment
result is null for path not related
result.relativePath is '' if the input was a root path, or the full relative path
result.foundRoot is the closest root (or the input if exact match)
How is this intended to be handled for the multi-root feature?
It depends on your use-case of which I would like to learn more. Also there is getWorkspaceFolder which gives you undefined when called with a workspace folder
I did see that function, and a reference to a (semi-) similar issue at #31553, but there is still some usability issues, either way. getWorkspaceFolder of course doesn't get the relative path, and how does the getRelativePath behave with a workspace root as the input in either case?
initially found with VSCode Version: Code - Insiders 1.16.0-insider (aa42e6e, 2017-09-01T15:40:17.463Z)
workspace.asRelativePath returns unexpected values in two ways:
workspace.asRelativePath(workspace.rootPath)
does not return '' or './'ok, so the documentation says
I'll give that part of it a pass, as the root is technically not a child.
It does, however, return a modified string, instead of the input: the input's drive backslash is returned as a forward slash.
This is not specific to the root, however. Any \ gets converted to /
const rel = workspace.asRelativePath('D:\\BAR\\FOO') // d:/bar/foo
expected behavior is to actually return the input as specified, so the following code would be valid:
having to do a separate test for (testPath === workspace.rootPath) is not ideal, either. How is this intended to be handled for the multi-root feature? Will it still return the testPath?
Perhaps now would be a great time to make this feature more usable, and create a better function that clarifies and makes more usable the different use cases, rather than the current solution of having asRelativePath report different things depending on the project setup (yuk!) and environment
suggested api:
result is null for path not related
result.relativePath is '' if the input was a root path, or the full relative path
result.foundRoot is the closest root (or the input if exact match)
ideally:
but that could be a stretch goal
The text was updated successfully, but these errors were encountered: