Add REVERSE_RELATIVE_FILEPATH snippet variable and expand cross-platform/remote/out-of-workspace test coverage#315155
Add REVERSE_RELATIVE_FILEPATH snippet variable and expand cross-platform/remote/out-of-workspace test coverage#315155
REVERSE_RELATIVE_FILEPATH snippet variable and expand cross-platform/remote/out-of-workspace test coverage#315155Conversation
Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/90968350-ad07-450f-8ad9-ce68bef9849a Co-authored-by: dmitrivMS <9581278+dmitrivMS@users.noreply.github.com>
REVERSE_RELATIVE_FILEPATH snippet variable
| } else { | ||
| assertVariableResolve(resolver, 'RELATIVE_FILEPATH', 'files\\text.txt'); | ||
| } | ||
| assertVariableResolve(resolver, 'REVERSE_RELATIVE_FILEPATH', '..'); |
There was a problem hiding this comment.
Added broader coverage for REVERSE_RELATIVE_FILEPATH in fc686605 (including deeply nested paths, workspace root, out-of-workspace, and backslash separator behavior).
There was a problem hiding this comment.
@copilot I don't see any tests for Windows paths (C:...).
Also, what happens in remote scenarios?
There was a problem hiding this comment.
Added explicit coverage in 9483cf96/e1f10a2b for Windows drive paths (C:\workspace\dir\sub\text.txt -> ..\\..) and remote URIs: in-workspace remote paths resolve to parent traversal (..), while remote out-of-workspace paths resolve to undefined.
There was a problem hiding this comment.
@copilot we should probably use a switch instead of else if tree here...
There was a problem hiding this comment.
Updated ModelBasedVariableResolver.resolve to use a switch and extracted reverse-path logic into a helper in 6292b69a (with follow-up polish in fc686605).
Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/ad126469-3f4a-47aa-bc06-a4affd3929e7 Co-authored-by: dmitrivMS <9581278+dmitrivMS@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/ad126469-3f4a-47aa-bc06-a4affd3929e7 Co-authored-by: dmitrivMS <9581278+dmitrivMS@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/ad126469-3f4a-47aa-bc06-a4affd3929e7 Co-authored-by: dmitrivMS <9581278+dmitrivMS@users.noreply.github.com>
REVERSE_RELATIVE_FILEPATH snippet variableREVERSE_RELATIVE_FILEPATH snippet variable and refine resolver/tests
| } else { | ||
| assertVariableResolve(resolver, 'RELATIVE_FILEPATH', 'files\\text.txt'); | ||
| } | ||
| assertVariableResolve(resolver, 'REVERSE_RELATIVE_FILEPATH', '..'); |
There was a problem hiding this comment.
@copilot I don't see any tests for Windows paths (C:...).
Also, what happens in remote scenarios?
| } | ||
|
|
||
| return undefined; | ||
| private _resolveReverseRelativeFilepath(): string | undefined { |
There was a problem hiding this comment.
@copilot what will happen if file is not in workspace? if it's above workspace?
There was a problem hiding this comment.
For files outside the workspace (including above a workspace root), REVERSE_RELATIVE_FILEPATH resolves to undefined and RELATIVE_FILEPATH stays absolute. I added explicit coverage for the “above workspace” case in 78474ed5.
Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/7cc9fe0d-9fc5-4b68-aa98-3f0997bd744d Co-authored-by: dmitrivMS <9581278+dmitrivMS@users.noreply.github.com>
Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/7cc9fe0d-9fc5-4b68-aa98-3f0997bd744d Co-authored-by: dmitrivMS <9581278+dmitrivMS@users.noreply.github.com>
REVERSE_RELATIVE_FILEPATH snippet variable and refine resolver/testsREVERSE_RELATIVE_FILEPATH snippet variable and expand cross-platform/remote test coverage
Agent-Logs-Url: https://github.com/microsoft/vscode/sessions/2ace4b45-56f1-46d2-ad23-8a45c873f723 Co-authored-by: dmitrivMS <9581278+dmitrivMS@users.noreply.github.com>
REVERSE_RELATIVE_FILEPATH snippet variable and expand cross-platform/remote test coverageREVERSE_RELATIVE_FILEPATH snippet variable and expand cross-platform/remote/out-of-workspace test coverage
Description
Adds a reverse companion to
RELATIVE_FILEPATHso snippets can compute a path from the current file back to the workspace folder.Snippet variable surface
REVERSE_RELATIVE_FILEPATH.Resolution behavior
ModelBasedVariableResolverusing existing label-service relative path behavior.undefinedwhen the file is not in a workspace folder context..when the file is at workspace root...,../.., etc. (platform separator aware) for nested paths.switchand extracted reverse-path computation into a dedicated helper for readability/maintainability.Docs and grammar parity
snippet.md).snippets.tmLanguage.json) so the new variable is recognized in snippet JSON.{ "Print reverse path": { "prefix": "revpath", "body": "from ${REVERSE_RELATIVE_FILEPATH}" } }Testing
undefined),..,../..),C:\...),npm run compile-check-ts-nativenpm run test-node -- --grep "Snippet Variables Resolver"