[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
emacs-29 0d98fac6bb: (ruby-ts-add-log-current-function): Fix when betwee
From: |
Dmitry Gutov |
Subject: |
emacs-29 0d98fac6bb: (ruby-ts-add-log-current-function): Fix when between two methods |
Date: |
Tue, 3 Jan 2023 17:39:12 -0500 (EST) |
branch: emacs-29
commit 0d98fac6bbc19c7728d42d6196adf4d392ba3132
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
(ruby-ts-add-log-current-function): Fix when between two methods
* 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.
---
lisp/progmodes/ruby-ts-mode.el | 7 ++++++-
test/lisp/progmodes/ruby-mode-tests.el | 3 +++
test/lisp/progmodes/ruby-ts-mode-tests.el | 3 +++
3 files changed, 12 insertions(+), 1 deletion(-)
diff --git a/lisp/progmodes/ruby-ts-mode.el b/lisp/progmodes/ruby-ts-mode.el
index c086214a11..5c173ad24c 100644
--- a/lisp/progmodes/ruby-ts-mode.el
+++ b/lisp/progmodes/ruby-ts-mode.el
@@ -850,7 +850,12 @@ The hash (#) is for instance methods only which are methods
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 "#")
diff --git a/test/lisp/progmodes/ruby-mode-tests.el
b/test/lisp/progmodes/ruby-mode-tests.el
index 9687231dbf..8a75c83d2c 100644
--- a/test/lisp/progmodes/ruby-mode-tests.el
+++ b/test/lisp/progmodes/ruby-mode-tests.el
@@ -537,9 +537,12 @@ VALUES-PLIST is a list with alternating index and value
elements."
| 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 ()
diff --git a/test/lisp/progmodes/ruby-ts-mode-tests.el
b/test/lisp/progmodes/ruby-ts-mode-tests.el
index aa1ab1e260..b2c990f8e5 100644
--- a/test/lisp/progmodes/ruby-ts-mode-tests.el
+++ b/test/lisp/progmodes/ruby-ts-mode-tests.el
@@ -141,9 +141,12 @@ The whitespace before and including \"|\" on each line is
removed."
| 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 ()
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- emacs-29 0d98fac6bb: (ruby-ts-add-log-current-function): Fix when between two methods,
Dmitry Gutov <=