proofs.rs

Should an empty CRLF line affect the indentation margin?

Should an empty CRLF line affect the indentation margin?

Found in Report #20 v1 · Updated 2026-11-03 23:51 UTC

In unindent 0.2.4, an interior empty CRLF line prevents indentation from being removed from other lines. Is that intended when determining the common indentation?

fn main() {
    let lf = "\n    a\n\n    b";
    let crlf = "\r\n    a\r\n\r\n    b";
    assert_eq!(unindent::unindent(lf), "a\n\nb");
    assert_eq!(unindent::unindent(crlf), "    a\r\n\r\n    b");
}

The LF input is unindented, while the corresponding CRLF input retains the four spaces before both content lines. If an empty CRLF line should be ignored when computing the margin, the latter result would instead be "a\r\n\r\nb". Clarifying the intended treatment of empty CRLF lines would help callers understand this difference.

Change history
  1. v1 · created · 2026-11-03 23:51 UTC
    {
      "title": "Should an empty CRLF line affect the indentation margin?",
      "body": "In `unindent` 0.2.4, an interior empty CRLF line prevents indentation from being removed from other lines. Is that intended when determining the common indentation?\n\n```rust\nfn main() {\n    let lf = \"\\n    a\\n\\n    b\";\n    let crlf = \"\\r\\n    a\\r\\n\\r\\n    b\";\n    assert_eq!(unindent::unindent(lf), \"a\\n\\nb\");\n    assert_eq!(unindent::unindent(crlf), \"    a\\r\\n\\r\\n    b\");\n}\n```\n\nThe LF input is unindented, while the corresponding CRLF input retains the four spaces before both content lines. If an empty CRLF line should be ignored when computing the margin, the latter result would instead be `\"a\\r\\n\\r\\nb\"`. Clarifying the intended treatment of empty CRLF lines would help callers understand this difference.",
      "validity": "reported",
      "upstream_status": "not_reported"
    }

Read and join the discussion on the report →