-
Notifications
You must be signed in to change notification settings - Fork 0
Fix wrapping for backslash hard breaks #94
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,4 @@ | ||
| Scenarios live under `tests/features/`. Step implementations in `tests` share \ | ||
| a common `World` struct that uses `figment::Jail` for isolation. Each scenario | ||
| demonstration example \ | ||
| executes asynchronously with `tokio`. |
| Original file line number | Diff line number | Diff line change |
|---|---|---|
| @@ -0,0 +1,3 @@ | ||
| Scenarios live under `tests/features/`. Step implementations in `tests` share \ | ||
| a common `World` struct that uses `figment::Jail` for isolation. Each scenario demonstration example \ | ||
| executes asynchronously with `tokio`. |
| Original file line number | Diff line number | Diff line change | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|---|
|
|
@@ -794,6 +794,35 @@ fn test_preserve_hard_line_breaks() { | |||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq!(output[1], "Line two follows."); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn test_wrap_hard_linebreak_backslash() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let input: Vec<String> = include_lines!("data/hard_linebreak_input.txt"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let expected: Vec<String> = include_lines!("data/hard_linebreak_expected.txt"); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq!(process_stream(&input), expected); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| fn test_wrap_hard_linebreak_backslash_edge_cases() { | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let input = lines_vec!( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "This line ends with two backslashes: \\\\", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "This line ends with a single backslash: \\", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| " \\ ", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "\\", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Text before \\ and after", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| " \\", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| let expected = lines_vec!( | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "This line ends with two backslashes: \\\\ This line ends with a single backslash:", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "\\", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "\\", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "\\", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "Text before \\ and after \\", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| "", | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| ); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+806
to
+822
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. suggestion (testing): Consider adding a test case for a line ending with an odd number of backslashes greater than one. Please add a test case with a line ending in three backslashes to ensure correct handling of odd numbers of trailing backslashes.
Suggested change
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| assert_eq!(process_stream(&input), expected); | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
Comment on lines
+815
to
+823
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. 💡 Verification agent 🧩 Analysis chainVerify the expected test outputs match the implementation. The expected outputs suggest specific behaviour for backslash line breaks. Ensure these expectations align with the actual implementation in 🏁 Script executed: #!/bin/bash
# Description: Verify the backslash line break behaviour matches test expectations
# Expected: Lines with odd trailing backslashes should create hard breaks
# Test the actual behaviour with the edge case inputs
echo "Testing backslash line break behaviour..."
# Check if the wrap_text function properly handles these cases
ast-grep --pattern 'fn wrap_text($_, $_) -> $_ {
$$$
}'Length of output: 152 🏁 Script executed: #!/bin/bash
# Locate process_stream implementation
rg -n "fn process_stream"
# Locate wrap_text implementation
rg -n "fn wrap_text" || echo "No direct wrap_text; searching usage"
rg -n "wrap_text"
# Find the wrap.rs file
WRAP_FILE=$(find src -name wrap.rs | head -n1)
echo "wrap.rs found at: $WRAP_FILE"
# Display the first 200 lines of wrap.rs for context
sed -n '1,200p' "$WRAP_FILE"Length of output: 8807 🏁 Script executed: #!/bin/bash
# Display integration test around backslash behaviour
echo "=== Integration Test Snippet ==="
sed -n '780,860p' tests/integration.rs
# Display process_stream_inner implementation to inspect hard-break logic
echo -e "\n=== process.rs (lines 1–200) ==="
sed -n '1,200p' src/process.rsLength of output: 5645 🏁 Script executed: #!/bin/bash
echo "=== wrap_text definition ==="
sed -n '200,360p' src/wrap.rs
echo -e "\n=== hard_break detection ==="
grep -n "hard_break" -n src/wrap.rsLength of output: 5434 Update backslash edge-case test expected outputs Adjust the • File: tests/integration.rs -let expected = lines_vec!(
- "This line ends with two backslashes: \\\\ This line ends with a single backslash:",
- "\\",
- "\\",
- "\\",
- "Text before \\ and after \\",
- "",
-);
+let expected = lines_vec!(
+ "This line ends with two backslashes: \\\\ This line ends with a single backslash:\\",
+ "\\",
+ "\\",
+ "Text before \\ and after \\",
+ "",
+);This removes the extra lone backslash line and preserves the trailing backslash on the first combined line. 📝 Committable suggestion
Suggested change
🤖 Prompt for AI Agents |
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| } | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| #[test] | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// Tests that `process_stream` preserves complex table formatting without modification. | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
| /// | ||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
|
|
||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||||
Uh oh!
There was an error while loading. Please reload this page.