Feature predefined variable extension#153
Merged
telesoho merged 6 commits intoMay 2, 2026
Merged
Conversation
…ystem with Python-style slicing support.
- Added `${basePath}` variable to render root-relative path (e.g. `/images/...`).
- Implemented Python-style slicing (`start:end`) for variable expansion, e.g. `${filePath|:-1}`.
- Step slicing (e.g. `[::2]`, `[::-1]`) is not supported.
- Supported variables for slicing: `${filePath}`, `${fileWorkspaceFolder}`, `${relativeFileDirname}`.
- Added new test case: "predefined variables slicing test" to verify Python-style slicing behavior (|-1, 0:2, :-1 supported; ::2 step not supported). - Extended Predefine constructor to allow injection for testing purposes.
- Remove test console.log
Owner
|
In Ubuntu and macOS environments, the "predefined variables slicing test" unit test failed to pass. Could you please check it? |
- Replaced hardcoded Windows-style path "C:\" with OS-specific strings - Ensured tests run correctly on both Windows and Ubuntu
- Ensures correct handling of root (e.g. "C:\\" vs "C:"; "/") - Use Node.js path API to avoid direct path string manipulation - Keep path representation platform-dependent - Improves cross-platform consistency between Windows and Linux
- Use path.resolve for customBasePath to ensure consistent root reference - Prevent prepending slashes to paths that are already absolute (e.g., cross-drive paths on Windows)
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
Add this suggestion to a batch that can be applied as a single commit.This suggestion is invalid because no changes were made to the code.Suggestions cannot be applied while the pull request is closed.Suggestions cannot be applied while viewing a subset of changes.Only one suggestion per line can be applied in a batch.Add this suggestion to a batch that can be applied as a single commit.Applying suggestions on deleted lines is not supported.You must change the existing code in this line in order to create a valid suggestion.Outdated suggestions cannot be applied.This suggestion has been applied or marked resolved.Suggestions cannot be applied from pending reviews.Suggestions cannot be applied on multi-line comments.Suggestions cannot be applied while the pull request is queued to merge.Suggestion cannot be applied right now. Please check back later.
Summary
Enhancement: Add
${basePath}, slicing support, and constructor injection for Predefine.Description
I’ve implemented several improvements to the variable expansion system:
${basePath}variable for rendering Markdown root‑relative paths (e.g. /images/...).${filePath},${fileWorkspaceFolder},${relativeFileDirname}.Syntax examples:
Motivation
This enhancement provides more flexibility in handling file paths and workspace‑relative paths. Developers can now manipulate paths more easily when working with Markdown paste operations.
Constructor injection also improves testability by allowing mock values to be injected during unit tests.
Testing