branch: elpa/evil-matchit
commit c04f8f480cbb39842376c5f93472f67f44ee1637
Author: Sergio Gil PĂ©rez de la Manga <[email protected]>
Commit: GitHub <[email protected]>

    Match Ruby's begin also when it's not on the beginning of the line
    
    This is a common idiom in Ruby (e.g. 
https://www.justinweiss.com/articles/4-simple-memoization-patterns-in-ruby-and-one-gem/#multi-line-memoization;
 it's even enforced by the popular Rubocop style checker: 
https://rubocop.readthedocs.io/en/stable/cops_style/#stylemultilinememoization) 
but it confuses evil-matchit:
    
    ```ruby
    class C
      def m # evil-matchit keeps jumping between here
        @v ||= begin
                 blah
               end # and here
      end
    end
    ```
    
    Since no regular expression matches, evil-matchit skips the `begin` and 
matches the wrong `end`.
    
    This change seems to fix it, but I'm not sure at all that it's the right 
way. Please consider this more a bug report with a proof of concept more than a 
pull request, you can probably find a better fix :smile_cat:
---
 evil-matchit-ruby.el | 1 +
 1 file changed, 1 insertion(+)

diff --git a/evil-matchit-ruby.el b/evil-matchit-ruby.el
index 45a0bf21a2..9bc408afa5 100644
--- a/evil-matchit-ruby.el
+++ b/evil-matchit-ruby.el
@@ -36,6 +36,7 @@
     ("^[ \t]*\\([a-z]+\\)\\( .*\\| *\\)$" 1)
     ("^.* \\(do\\) |[a-z0-9A-Z_, *]+|$" 1)
     ("^.* \\(do\\) *$" 1)
+    ("^.* \\(begin\\) *$" 1)
     ("^.* \\(end\\)\\..*$" 1)))
 
 (defvar evilmi-ruby-match-tags

Reply via email to