[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]
master 39646c822b: Fix Ruby indentation with double splat as first block
From: |
Dmitry Gutov |
Subject: |
master 39646c822b: Fix Ruby indentation with double splat as first block param |
Date: |
Mon, 25 Apr 2022 22:37:07 -0400 (EDT) |
branch: master
commit 39646c822bf9a3fb1ccdca0a7a5d192e607c03c3
Author: Dmitry Gutov <dgutov@yandex.ru>
Commit: Dmitry Gutov <dgutov@yandex.ru>
Fix Ruby indentation with double splat as first block param
* lisp/progmodes/ruby-mode.el (ruby-smie--forward-token)
(ruby-smie--backward-token): Tokenize "**" separately from "|".
Problem reported at https://github.com/dgutov/robe/issues/136.
---
lisp/progmodes/ruby-mode.el | 4 ++--
test/lisp/progmodes/ruby-mode-resources/ruby.rb | 9 +++++++++
2 files changed, 11 insertions(+), 2 deletions(-)
diff --git a/lisp/progmodes/ruby-mode.el b/lisp/progmodes/ruby-mode.el
index fdc8164dc0..a197724634 100644
--- a/lisp/progmodes/ruby-mode.el
+++ b/lisp/progmodes/ruby-mode.el
@@ -508,7 +508,7 @@ This only affects the output of the command
`ruby-toggle-block'."
((member tok '("unless" "if" "while" "until"))
(if (save-excursion (forward-word-strictly -1) (ruby-smie--bosp))
tok "iuwu-mod"))
- ((string-match-p "\\`|[*&]?\\'" tok)
+ ((string-match-p "\\`|[*&]*\\'" tok)
(forward-char (- 1 (length tok)))
(setq tok "|")
(cond
@@ -561,7 +561,7 @@ This only affects the output of the command
`ruby-toggle-block'."
((ruby-smie--closing-pipe-p) "closing-|")
(t tok)))
((string-match-p "\\`[^|]+|\\'" tok) "closing-|")
- ((string-match-p "\\`|[*&]\\'" tok)
+ ((string-match-p "\\`|[*&]*\\'" tok)
(forward-char 1)
(substring tok 1))
((and (equal tok "") (eq ?\\ (char-before)) (looking-at "\n"))
diff --git a/test/lisp/progmodes/ruby-mode-resources/ruby.rb
b/test/lisp/progmodes/ruby-mode-resources/ruby.rb
index f31cea86a5..0c206b1e0c 100644
--- a/test/lisp/progmodes/ruby-mode-resources/ruby.rb
+++ b/test/lisp/progmodes/ruby-mode-resources/ruby.rb
@@ -491,3 +491,12 @@ in ['th', orig_text, 'en', trans_text]
in {'th' => orig_text, 'ja' => trans_text}
puts "Japanese translation: #{orig_text} => #{trans_text}"
end
+
+# Tokenizing "**" and "|" separately.
+def resolve(**args)
+ members = proc do |**args|
+ p(**args)
+ end
+
+ member.call(**args)
+end
[Prev in Thread] |
Current Thread |
[Next in Thread] |
- master 39646c822b: Fix Ruby indentation with double splat as first block param,
Dmitry Gutov <=