Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

relativeFileDirname gives empty string when the Dirname equals to current working directory #108588

Merged
merged 1 commit into from
Oct 13, 2020

Conversation

alexr00
Copy link
Member

@alexr00 alexr00 commented Oct 13, 2020

Fixes #108437

@@ -278,7 +278,8 @@ export class AbstractVariableResolverService implements IConfigurationResolverSe
}
const dirname = paths.dirname(getFilePath());
if (folderUri || argument) {
return paths.relative(this.fsPath(getFolderUri()), dirname);
const relative = paths.relative(this.fsPath(getFolderUri()), dirname);
return relative.length === 0 ? '.' : relative;
Copy link
Member Author

Choose a reason for hiding this comment

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

We used to call paths.normalize(relative), which does the conversion from empty string to '.'. Since it isn't safe to call normalize on a path that could come from a remote, I removed it. In this case though, we still need the '.' instead of empty string.

Copy link
Contributor

Choose a reason for hiding this comment

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

There's potential for refactoring here as fsPath and path.relative should not be used on remote URIs.

But for the fix release the change is minimal and good.

@alexr00 alexr00 self-assigned this Oct 13, 2020
@aeschli aeschli self-requested a review October 13, 2020 13:10
@@ -278,7 +278,8 @@ export class AbstractVariableResolverService implements IConfigurationResolverSe
}
const dirname = paths.dirname(getFilePath());
if (folderUri || argument) {
return paths.relative(this.fsPath(getFolderUri()), dirname);
const relative = paths.relative(this.fsPath(getFolderUri()), dirname);
return relative.length === 0 ? '.' : relative;
Copy link
Contributor

Choose a reason for hiding this comment

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

There's potential for refactoring here as fsPath and path.relative should not be used on remote URIs.

But for the fix release the change is minimal and good.

@alexr00 alexr00 merged commit 88d189d into release/1.50 Oct 13, 2020
@alexr00 alexr00 deleted the alexr00/issue108437 branch October 13, 2020 13:11
alexr00 added a commit that referenced this pull request Oct 13, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 4, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants