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
Fix #79428 - add "$WORKSPACE_FOLDER" for snippet #79764
Conversation
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
please add tests
@jrieken I added tests. |
@@ -272,13 +274,31 @@ export class WorkspaceBasedVariableResolver implements VariableResolver { | |||
} | |||
|
|||
if (isSingleFolderWorkspaceIdentifier(workspaceIdentifier)) { | |||
return path.basename(workspaceIdentifier.path); | |||
if (variable.name === 'WORKSPACE_NAME') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
this repeated-if-else is a little ugly, can't you change it be two methods, like _resolveWorkspaceName
and _resoveWorkspacePath
?
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I can do it later.
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
@jrieken I separate it into two functions.
@@ -272,13 +274,31 @@ export class WorkspaceBasedVariableResolver implements VariableResolver { | |||
} | |||
|
|||
if (isSingleFolderWorkspaceIdentifier(workspaceIdentifier)) { | |||
return path.basename(workspaceIdentifier.path); | |||
if (variable.name === 'WORKSPACE_NAME') { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
sure, I can do it later.
Add a new snippet variable
WORKSPACE_FOLDER
.