branch: elpa/nix-mode
commit 1697f1806698e1e4f7be8ed4638cac5c6ac85c8f
Author: Matthew Bauer <[email protected]>
Commit: Matthew Bauer <[email protected]>

    Fix #128
---
 nix-mode.el                   | 4 ++--
 tests/nix-mode-tests.el       | 4 ++++
 tests/testcases/issue-128.nix | 6 ++++++
 3 files changed, 12 insertions(+), 2 deletions(-)

diff --git a/nix-mode.el b/nix-mode.el
index b0b0b77159..0c1c0596f6 100644
--- a/nix-mode.el
+++ b/nix-mode.el
@@ -733,8 +733,8 @@ not to any other arguments."
                                 (let ((line (buffer-substring-no-properties 
(line-beginning-position) (line-end-position))))
                                   ;; Then regex-match strings at the end of 
the line to detect if we need to indent the line after.
                                   ;; We could probably add more things to look 
for here in the future.
-                                  (if (or (string-match "let$" line)
-                                          (string-match "import$" line)
+                                  (if (or (string-match "\\blet$" line)
+                                          (string-match "\\bimport$" line)
                                           (string-match "\\[$" line)
                                           (string-match "=$" line)
                                           (string-match "\($" line)
diff --git a/tests/nix-mode-tests.el b/tests/nix-mode-tests.el
index 106ad3ba13..6b4564e827 100644
--- a/tests/nix-mode-tests.el
+++ b/tests/nix-mode-tests.el
@@ -245,5 +245,9 @@ Related issue: https://github.com/NixOS/nix-mode/issues/94";
   "Proper indentation of let expressions."
   (with-nix-mode-test ("smie-let.nix" :indent 'smie-indent-line)))
 
+(ert-deftest nix-mode-test-indent-issue-128 ()
+  "Proper indentation of let expressions."
+  (with-nix-mode-test ("issue-128.nix" :indent 'nix-indent-line)))
+
 (provide 'nix-mode-tests)
 ;;; nix-mode-tests.el ends here
diff --git a/tests/testcases/issue-128.nix b/tests/testcases/issue-128.nix
new file mode 100644
index 0000000000..8291fec36b
--- /dev/null
+++ b/tests/testcases/issue-128.nix
@@ -0,0 +1,6 @@
+[
+  foo
+  bar
+  networkmanagerapplet
+  baz
+]

Reply via email to