emacs-elpa-diffs
[Top][All Lists]
Advanced

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

[elpa] externals/phps-mode 59ba835 086/405: Fixed issue with wrong inden


From: Stefan Monnier
Subject: [elpa] externals/phps-mode 59ba835 086/405: Fixed issue with wrong indentation at trailing opening brace
Date: Sat, 13 Jul 2019 09:59:49 -0400 (EDT)

branch: externals/phps-mode
commit 59ba835b2c85b639d82684ba3311a30d08df1d6e
Author: Christian Johansson <address@hidden>
Commit: Christian Johansson <address@hidden>

    Fixed issue with wrong indentation at trailing opening brace
---
 phps-functions.el      | 9 +++++----
 phps-test-functions.el | 9 +++++++--
 2 files changed, 12 insertions(+), 6 deletions(-)

diff --git a/phps-functions.el b/phps-functions.el
index 543996c..e915557 100644
--- a/phps-functions.el
+++ b/phps-functions.el
@@ -65,12 +65,13 @@
                  (indent-end (+ end-bracket-level end-parenthesis-level))
                  (indent-level indent-start)
                  (indent-adjust 0))
-            (message "indent-start %s, indent-end %s" indent-start indent-end)
+            ;; (message "indent-start %s, indent-end %s" indent-start 
indent-end)
 
             ;; When bracket count at start is larger than bracket count at end
             (when (and
                    (boundp 'phps-mode/lexer-tokens)
-                   (not (equal indent-start indent-end))
+                   (or (not (equal start-bracket-level end-bracket-level))
+                       (not (equal start-parenthesis-level 
end-parenthesis-level)))
                    start-token-number
                    end-token-number)
               (let ((token-number start-token-number)
@@ -104,13 +105,13 @@
                                      (string= token "]")
                                      (string= token ";")
                                      (eq token 'T_CLOSE_TAG))))
-                      (message "Token %s - %s in %s was invalid, line start 
%s" token token-number tokens line-start)
+                      ;; (message "Token %s - %s in %s was invalid, line start 
%s" token token-number tokens line-start)
                       (setq valid-tokens nil)))
 
                   (setq token-number (+ token-number 1)))
 
                 (when valid-tokens
-                  (message "Tokens was valid, decreasing indent %s - %s" 
(line-beginning-position) (line-end-position))
+                  ;; (message "Tokens was valid, decreasing indent %s - %s" 
(line-beginning-position) (line-end-position))
 
                   ;; If last token is a opening brace indent line one lesser 
column
                   (when last-token-is-open-brace
diff --git a/phps-test-functions.el b/phps-test-functions.el
index 468bee7..f348e4d 100644
--- a/phps-test-functions.el
+++ b/phps-test-functions.el
@@ -145,8 +145,6 @@
    (let ((buffer-contents (buffer-substring-no-properties (point-min) 
(point-max))))
      (should (equal buffer-contents  "<?php\nif (empty(\n$this->var\n) && 
!empty($this->var)\n) {\n$this->var = 'abc123';\n}\n"))))
 
-  ;; TODO Test this
-
 
   )
 
@@ -223,8 +221,15 @@
    "<?php\n$variable = array(\n'random4');\n$variable = true;\n"
    (goto-char 29)
    (should (equal (list (list t 0 1 0 4 nil) (list t 0 0 0 7 nil)) 
(phps-mode/get-point-data))))
+
+  (phps-mode/with-test-buffer
+   "<?php\nif (empty(\n$this->var\n) && !empty($this->var)\n) {\n$this->var = 
'abc123';\n}\n"
+   (goto-char 54)
+   (should (equal (list (list t 0 1 0 16 nil) (list t 1 0 0 18 nil)) 
(phps-mode/get-point-data))))
+
   )
 
+
 ;; TODO Add tests for all examples here: https://www.php-fig.org/psr/psr-2/
 
 (defun phps-mod/test-functions ()



reply via email to

[Prev in Thread] Current Thread [Next in Thread]