* lisp/progmodes/ruby-ts-mode.el
(ruby-ts-add-log-current-function): Fix the case when point is
between two methods. 'treesit-node-at' returs the 'def' node of
the method after point in such case, so it behaved like point was
inside the method below.
* test/lisp/progmodes/ruby-ts-mode-tests.el
(ruby-ts-add-log-current-method-outside-of-method):
Update the test case.
* test/lisp/progmodes/ruby-mode-tests.el
(ruby-add-log-current-method-outside-of-method):
Mirror that change.
dot (.) is used. Double colon (::) is used between classes. The
leading double colon is not added."
(let* ((node (treesit-node-at (point)))
- (method (treesit-parent-until node (ruby-ts--type-pred ruby-ts--method-regex)))
+ (method-pred
+ (lambda (node)
+ (and (<= (treesit-node-start node) (point))
+ (>= (treesit-node-end node) (point))
+ (string-match-p ruby-ts--method-regex (treesit-node-type node)))))
+ (method (treesit-parent-until node method-pred t))
(class (or method node))
(result nil)
(sep "#")
| def foo
| end
| _
+ | def bar
+ | end
| end
|end")
(search-backward "_")
+ (delete-char 1)
(should (string= (ruby-add-log-current-method)"M::C"))))
(ert-deftest ruby-add-log-current-method-in-singleton-class ()
| def foo
| end
| _
+ | def bar
+ | end
| end
|end")
(search-backward "_")
+ (delete-char 1)
(should (string= (ruby-ts-add-log-current-function) "M::C"))))
(ert-deftest ruby-ts-add-log-current-method-in-singleton-class ()