Feature/unescape backslashes config#298
Open
qualityisaculture wants to merge 2 commits intocucumber:mainfrom
Open
Feature/unescape backslashes config#298qualityisaculture wants to merge 2 commits intocucumber:mainfrom
qualityisaculture wants to merge 2 commits intocucumber:mainfrom
Conversation
Added a new configuration option `cucumber.unescapeBackslashes` that allows users to unescape backslashes in Cucumber Expression patterns from JavaScript or TypeScript step definitions. When enabled, this setting converts escaped backslashes (`\\`) to regular backslashes (`\`) in file content read by cucumber libraries. This fixes an issue where the library sometimes interprets `\\/` as two backslashes instead of one when reading step definitions that use alternative text behavior in Cucumber Expressions. Changes: - Add `cucumber.unescapeBackslashes` boolean config option (default: false) - Update VscodeFiles.readFile() to apply backslash unescaping when enabled - Add documentation in README.md with explanation and use case - Update update-settings-docs.sh script to sync new config - Update CHANGELOG.md with new feature The config is read dynamically on each file read, so changes take effect immediately without requiring an extension restart.
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.
🤔 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: