((n-p-gp nil "body_statement" ,ruby-ts--method-regex) ;other statements
(ruby-ts--align-keywords ruby-ts--grand-parent-node) ruby-indent-level)
+ ;; Quirk of the ruby parser: these "alignable" nodes don't
+ ;; have the "container" child node when there are no
+ ;; statements inside. Thus we have to have a separate rule
+ ;; for the "empty if/unless/case/def" situation.
+ ((match "\\`\\'" "\\`\\(?:if\\|unless\\|case\\|method\\)\\'")
+ (ruby-ts--align-keywords ruby-ts--parent-node) ruby-indent-level)
+
;; Chained calls:
;; if `ruby-align-chained-calls' is true, the first query
;; matches and the node is aligned under the first dot (.);
(funcall indent-line-function)
(should (= (current-indentation) ruby-indent-level))))
+(ert-deftest ruby-ts-indent-empty-if-else ()
+ (skip-unless (treesit-ready-p 'ruby t))
+ (let* ((str "c = if foo
+ zz
+ else
+ zz
+ end
+"))
+ (ruby-ts-with-temp-buffer str
+ (goto-char (point-min))
+ (dotimes (_ 2)
+ (re-search-forward "^ *zz")
+ (replace-match "")
+ (funcall indent-line-function)
+ (should (= (current-indentation) 6))))))
+
(ert-deftest ruby-ts-add-log-current-method-examples ()
(skip-unless (treesit-ready-p 'ruby t))
(let ((pairs '(("foo" . "#foo")