Skip to content
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
19 changes: 19 additions & 0 deletions src/wrap.rs
Original file line number Diff line number Diff line change
Expand Up @@ -431,4 +431,23 @@ mod tests {
.any(|l| l.contains("https://falcon.readthedocs.io"))
);
}

#[test]
fn wrap_text_respects_backslash_linebreaks() {
let input = vec![
"Scenarios live under `tests/features/`. Step implementations in `tests` share \\"
.to_string(),
"a common `World` struct that uses `figment::Jail` for isolation. Each scenario \\"
.to_string(),
"executes asynchronously with `tokio`.".to_string(),
];
let expected = vec![
"Scenarios live under `tests/features/`. Step implementations in `tests` share \\"
.to_string(),
"a common `World` struct that uses `figment::Jail` for isolation. Each scenario"
.to_string(),
"\\ executes asynchronously with `tokio`.".to_string(),
];
assert_eq!(wrap_text(&input, 80), expected);
}
Comment on lines +435 to +452
Copy link
Copy Markdown
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

💡 Verification agent

🧩 Analysis chain

Verify the test logic matches the expected backslash handling behaviour.

The test expects backslashes to be repositioned during wrapping, but examine the actual wrap_text function implementation. The function doesn't appear to have specific logic for handling backslash line continuations - it treats them as regular characters. This suggests the test may be documenting desired behaviour rather than testing current implementation.

Run the following script to verify the current wrap_text function behaviour with backslash line continuations:


🏁 Script executed:

#!/bin/bash
# Description: Test the actual behaviour of wrap_text with backslash line continuations
# Expected: Determine if the function currently handles backslashes as documented in the test

# Search for backslash handling logic in the wrap_text function
ast-grep --pattern 'fn wrap_text($$$) {
  $$$
}'

# Also search for any backslash-related logic in the entire file
rg -A 5 -B 5 '\\\\' src/wrap.rs

Length of output: 924


Implement backslash line‐continuation support in wrap_text

wrap_text currently treats backslashes as ordinary characters, so the new wrap_text_respects_backslash_linebreaks test fails. Add explicit handling for trailing \ to preserve line breaks as documented:

• File: src/wrap.rs
Function: wrap_text

• In each input line, detect a trailing \ before wrapping.
– Strip the \ from the end of the current line.
– Perform normal word-wrapping on the remaining text.
– Prepend \ to the next wrapped line and continue wrapping its words.

• Verify behavior by re-running wrap_text_respects_backslash_linebreaks.

🤖 Prompt for AI Agents
In src/wrap.rs around lines 435 to 452, the wrap_text function does not
currently handle trailing backslashes as line continuations, causing the
wrap_text_respects_backslash_linebreaks test to fail. Modify wrap_text to detect
if a line ends with a backslash, remove that backslash before wrapping, then
prepend a backslash and space ("\ ") to the start of the next wrapped line to
preserve the line break semantics. After implementing this, re-run the
wrap_text_respects_backslash_linebreaks test to confirm correct behavior.

}