fix: preserve booking method quoted string in open directive formatting#848
Open
polarmutex wants to merge 1 commit intomainfrom
Open
fix: preserve booking method quoted string in open directive formatting#848polarmutex wants to merge 1 commit intomainfrom
polarmutex wants to merge 1 commit intomainfrom
Conversation
Fixes #836. The formatter was calling `rest_content.find(char::is_alphabetic)` to skip leading whitespace before a currency token. When an `open` directive included a booking method (e.g. `"FIFO"`), this skipped the opening quote, producing corrupt output like `FXAIX FIFO"` instead of `FXAIX "FIFO"`. The fix: when `rest_content` starts with a `"`, treat it as a verbatim quoted token (booking method) and preserve it with a single leading space rather than stripping non-alphabetic prefix characters. Adds a regression test that covers the mangled-quote scenario and verifies idempotency of the formatter on open directives with booking methods. Co-Authored-By: Claude (claude-sonnet-4-6) <noreply@anthropic.com>
Codecov Report✅ All modified and coverable lines are covered by tests. Additional details and impacted files@@ Coverage Diff @@
## main #848 +/- ##
==========================================
+ Coverage 80.88% 80.91% +0.03%
==========================================
Files 31 31
Lines 12502 12522 +20
==========================================
+ Hits 10112 10132 +20
Misses 2390 2390
🚀 New features to boost your workflow:
|
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
Fixes #836.
The formatter was stripping the leading
"from booking method strings onopendirectives. For example:was being mangled to:
Root cause: In
generate_template_edits, the code usedrest_content.find(char::is_alphabetic)to skip leading whitespace/non-alpha chars before a currency token. When the rest content was a quoted booking method like"FIFO", it foundFat index 1 (skipping the"), producing the corrupted output.Fix: Check whether
rest_contentstarts with"before applying the alpha-search. If it does, it's a quoted token (booking method) and should be preserved verbatim with a single leading space.Test plan
test_open_directive_booking_method_preserved— verifies that"FIFO"booking methods onopendirectives are preserved intact after formatting