Feature/unescape backslashes config #298
Open
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.
🤔 What's changed?
Added a new configuration option
cucumber.unescapeBackslashesthat allows users to unescape backslashes in Cucumber Expression patterns when reading JavaScript or TypeScript step definition files.Implementation details:
cucumber.unescapeBackslashesboolean configuration option (default:false)VscodeFiles.readFile()to apply backslash unescaping to file content when the config is enabledFiles changed:
package.json- Added new config option definitionREADME.md- Added documentation section with explanation and use casescripts/update-settings-docs.sh- Updated to sync new config documentationsrc/VscodeFiles.ts- Implemented backslash unescaping logicsrc/test/suite/VscodeFiles.test.ts- Added test suite (4 new tests)CHANGELOG.md- Added entry under [Unreleased]⚡️ What's your motivation?
This change fixes an issue where the library sometimes interprets
\\/(two backslashes) instead of\/(one backslash) when reading step definitions from JavaScript/TypeScript source code. Specifically when using the badeball preprocessor with Cypress.The Problem:
In Cucumber Expressions, you need to escape a forward slash with a backslash (
\/) for alternative text behavior. In JavaScript source code, backslashes themselves must be escaped, so developers write"\\/"to achieve\/at runtime. However, when the extension reads these files, the library sometimes interprets\\/as two backslashes instead of one, causing incorrect pattern matching.The Solution:
This new config option converts escaped backslashes (
\\) back to regular backslashes (\) in file content, ensuring correct interpretation of Cucumber Expression patterns.🏷️ What kind of change is this?
This is a non-breaking change because:
false, maintaining existing behavior♻️ Anything particular you want feedback on?
readFile()call rather than caching it in the constructor. This ensures config changes take effect immediately, but I'm open to feedback if there's a better approach or performance concerns.📋 Checklist: