Repository: nix-community/nixpkgs-fmt (rust)

Issue:
multi-line string is indented wrong in paranthese
```
(let
  a = ''
    foo
  '';
 in a)
```

results in

```
(
  let
    a = ''
      foo
      '';
  in
    a
)
```

instead of

```
(
  let
    a = ''
      foo
    '';
  in
    a
)
```

a more practical example would be:

```
wpa_supplicant.overrideAttrs(old: {
  postBuild = ''
    echo foo
  '';
})
```

->

```
wpa_supplicant.overrideAttrs (
  old: {
    postBuild = ''
      echo foo
      '';
  }
)
```

Pull request:
tone down aggressive fast path check for idented strings
closes #83

bors r+

Patch:
diff --git a/.github/ISSUE_TEMPLATE/bug_report.md b/.github/ISSUE_TEMPLATE/bug_report.md
deleted file mode 100644
index 8ee9717..0000000
--- a/.github/ISSUE_TEMPLATE/bug_report.md
+++ /dev/null
@@ -1,27 +0,0 @@
----
-name: Bug report
-about: Create a report to help us improve
-title: ''
-labels: bug, needs triage
-assignees: ''
-
----
-
-**Describe the bug**
-A clear and concise description of what the bug is.
-
-**To Reproduce**
-Steps to reproduce the behavior:
-
-1. Run `nixpkgs-fmt ...'
-2. ...
-
-**Expected behavior**
-A clear and concise description of what you expected to happen.
-
-**System information**
-
-* `nixpkgs-fmt --version`
-
-**Additional context**
-Add any other context about the problem here.
diff --git a/.github/ISSUE_TEMPLATE/feature_request.md b/.github/ISSUE_TEMPLATE/feature_request.md
deleted file mode 100644
index b499831..0000000
--- a/.github/ISSUE_TEMPLATE/feature_request.md
+++ /dev/null
@@ -1,20 +0,0 @@
----
-name: Feature request
-about: Suggest an idea for this project
-title: ''
-labels: enhancement, needs triage
-assignees: ''
-
----
-
-**Is your feature request related to a problem? Please describe.**
-A clear and concise description of what the problem is. Ex. I'm always frustrated when [...]
-
-**Describe the solution you'd like**
-A clear and concise description of what you want to happen.
-
-**Describe alternatives you've considered**
-A clear and concise description of any alternative solutions or features you've considered.
-
-**Additional context**
-Add any other context or screenshots about the feature request here.
diff --git a/.github/ISSUE_TEMPLATE/formatting-issue.md b/.github/ISSUE_TEMPLATE/formatting-issue.md
deleted file mode 100644
index 51575dc..0000000
--- a/.github/ISSUE_TEMPLATE/formatting-issue.md
+++ /dev/null
@@ -1,21 +0,0 @@
----
-name: Formatting issue
-about: Use this template to discuss the formatting output
-title: ''
-labels: formatting, needs triage
-assignees: ''
-
----
-
-## Input
-```nix
-```
-
-## Output
-```nix
-```
-
-## Desired output
-
-```nix
-```
diff --git a/src/engine/fixes.rs b/src/engine/fixes.rs
index 4e39db9..46c2a45 100644
--- a/src/engine/fixes.rs
+++ b/src/engine/fixes.rs
@@ -63,16 +63,14 @@ fn fix_string_indentation(
         None => return,
     };
 
-    if target_indent == IndentLevel::from_len(common_indent) {
-        return;
-    }
-
-    for &range in content_ranges.iter() {
-        let delete = TextRange::offset_len(range.start(), min(common_indent, range.len()));
-        model.raw_edit(AtomEdit { delete, insert: target_indent.as_str().into() })
+    if target_indent != IndentLevel::from_len(common_indent) {
+        for &range in content_ranges.iter() {
+            let delete = TextRange::offset_len(range.start(), min(common_indent, range.len()));
+            model.raw_edit(AtomEdit { delete, insert: target_indent.as_str().into() })
+        }
     }
 
-    if last_line_is_blank {
+    if last_line_is_blank && last_indent.len() != TextUnit::of_str(target_indent.as_str()) {
         model.raw_edit(AtomEdit { delete: *last_indent, insert: target_indent.as_str().into() })
     }
 }
diff --git a/wasm/index.html b/wasm/index.html
index 3f4447a..f75fcf0 100644
--- a/wasm/index.html
+++ b/wasm/index.html
@@ -57,8 +57,6 @@
     <form action="https://github.com/nix-community/nixpkgs-fmt/issues/new" method=get>
       <input type="hidden" name="title" value="sample: ">
       <input type="hidden" name="body" id="issue-body" required>
-      <input type="hidden" name="labels" value="formatting, needs triage">
-      <input type="hidden" name="template" value="formatting-issue.md">
       <p>Not liking the result?</p>
       <button class="btn btn-primary" type=submit>Submit code sample</button>
     </form>


Test patch:
diff --git a/test_data/issue-83-1.bad.nix b/test_data/issue-83-1.bad.nix
new file mode 100644
index 0000000..cf98fb9
--- /dev/null
+++ b/test_data/issue-83-1.bad.nix
@@ -0,0 +1,5 @@
+let
+  a = ''
+    foo
+  '';
+ in a
diff --git a/test_data/issue-83-1.good.nix b/test_data/issue-83-1.good.nix
new file mode 100644
index 0000000..592c6ae
--- /dev/null
+++ b/test_data/issue-83-1.good.nix
@@ -0,0 +1,6 @@
+let
+  a = ''
+    foo
+    '';
+in
+  a
diff --git a/test_data/issue-83-2.bad.nix b/test_data/issue-83-2.bad.nix
new file mode 100644
index 0000000..3572d1a
--- /dev/null
+++ b/test_data/issue-83-2.bad.nix
@@ -0,0 +1,5 @@
+(let
+  a = ''
+    foo
+  '';
+ in a)
diff --git a/test_data/issue-83-2.good.nix b/test_data/issue-83-2.good.nix
new file mode 100644
index 0000000..77dfb64
--- /dev/null
+++ b/test_data/issue-83-2.good.nix
@@ -0,0 +1,8 @@
+(
+  let
+    a = ''
+      foo
+      '';
+  in
+    a
+)