irb 1.3.0 → 1.3.1

Sign up to get free protection for your applications and to get access to all the features.
checksums.yaml CHANGED
@@ -1,7 +1,7 @@
1
1
  ---
2
2
  SHA256:
3
- metadata.gz: 31185f1544129f656db53521cf32cd171bb8dbfb49a3826bcf9eeddf46928c64
4
- data.tar.gz: 1a48f904f93867f1242cc6e548e0acb5acf8767ec7e89eb543cd08025e7857f2
3
+ metadata.gz: e147abaf69084b92f2f7accaf7d83014b6c0f7b3b6cbe0cc9b9878c52baee8af
4
+ data.tar.gz: 9a770f98f44f4bf498c91a3d8546d13a1db418daa034639646c0df0c3720d23e
5
5
  SHA512:
6
- metadata.gz: 921e8d5c6306dbcfa7daafa8271dcadfa9f2707e315a81704e921b1d7111d6c1a1a958e8b3b615c1725c2e2a0a7dffa245a7fbd068383977cc8259f1282cf51b
7
- data.tar.gz: 8eaa9e728fd9f14a42fc08a729c9e8dc3ac8289257f26f6440fa38c29c7491caefa2611eb10d2a778a0664e8e7c29c6c8be9b3e1a91133c206e0364a61cd62ee
6
+ metadata.gz: f760ae68d08c7ae7f9f4ec07149935819f50df015a5f4a9453eca4a01574677ed5a29ae1c4eb8462b9cc92f5ad6b465b4e8b1c3f37748bd81ecde7159cf3a1c0
7
+ data.tar.gz: 3da91491f2e3928c8b619f120b6c6adcd020ed16760a4c176aee38bec5ca3964eb7cd0acc053a6a18dacec571b9a0b1e93d2a4c94a628a642b3b39bfd98b5284
@@ -38,6 +38,7 @@ Gem::Specification.new do |spec|
38
38
  "lib/irb/cmd/pushws.rb",
39
39
  "lib/irb/cmd/subirb.rb",
40
40
  "lib/irb/color.rb",
41
+ "lib/irb/color_printer.rb",
41
42
  "lib/irb/completion.rb",
42
43
  "lib/irb/context.rb",
43
44
  "lib/irb/easter-egg.rb",
data/lib/irb.rb CHANGED
@@ -578,6 +578,29 @@ module IRB
578
578
  end
579
579
  end
580
580
 
581
+ def convert_invalid_byte_sequence(str)
582
+ str = str.force_encoding(Encoding::ASCII_8BIT)
583
+ conv = Encoding::Converter.new(Encoding::ASCII_8BIT, Encoding::UTF_8)
584
+ dst = String.new
585
+ begin
586
+ ret = conv.primitive_convert(str, dst)
587
+ case ret
588
+ when :invalid_byte_sequence
589
+ conv.insert_output(conf.primitive_errinfo[3].dump[1..-2])
590
+ redo
591
+ when :undefined_conversion
592
+ c = conv.primitive_errinfo[3].dup.force_encoding(conv.primitive_errinfo[1])
593
+ conv.insert_output(c.dump[1..-2])
594
+ redo
595
+ when :incomplete_input
596
+ conv.insert_output(conv.primitive_errinfo[3].dump[1..-2])
597
+ when :finished
598
+ end
599
+ break
600
+ end while nil
601
+ dst
602
+ end
603
+
581
604
  def handle_exception(exc)
582
605
  if exc.backtrace && exc.backtrace[0] =~ /\/irb(2)?(\/.*|-.*|\.rb)?:/ && exc.class.to_s !~ /^IRB/ &&
583
606
  !(SyntaxError === exc) && !(EncodingError === exc)
@@ -587,49 +610,44 @@ module IRB
587
610
  irb_bug = false
588
611
  end
589
612
 
590
- if STDOUT.tty?
591
- attr = ATTR_TTY
592
- print "#{attr[1]}Traceback#{attr[]} (most recent call last):\n"
593
- else
594
- attr = ATTR_PLAIN
595
- end
596
- messages = []
597
- lasts = []
598
- levels = 0
599
613
  if exc.backtrace
600
- count = 0
601
- exc.backtrace.each do |m|
602
- m = @context.workspace.filter_backtrace(m) or next unless irb_bug
603
- count += 1
604
- if attr == ATTR_TTY
605
- m = sprintf("%9d: from %s", count, m)
614
+ order = nil
615
+ if '2.5.0' == RUBY_VERSION
616
+ # Exception#full_message doesn't have keyword arguments.
617
+ message = exc.full_message # the same of (highlight: true, order: bottom)
618
+ order = :bottom
619
+ elsif '2.5.1' <= RUBY_VERSION && RUBY_VERSION < '3.0.0'
620
+ if STDOUT.tty?
621
+ message = exc.full_message(order: :bottom)
622
+ order = :bottom
606
623
  else
607
- m = "\tfrom #{m}"
608
- end
609
- if messages.size < @context.back_trace_limit
610
- messages.push(m)
611
- elsif lasts.size < @context.back_trace_limit
612
- lasts.push(m).shift
613
- levels += 1
624
+ message = exc.full_message(order: :top)
625
+ order = :top
614
626
  end
627
+ else # '3.0.0' <= RUBY_VERSION
628
+ message = exc.full_message(order: :top)
629
+ order = :top
615
630
  end
616
- end
617
- if attr == ATTR_TTY
618
- unless lasts.empty?
619
- puts lasts.reverse
620
- printf "... %d levels...\n", levels if levels > 0
621
- end
622
- puts messages.reverse
623
- end
624
- m = exc.to_s.split(/\n/)
625
- print "#{attr[1]}#{exc.class} (#{attr[4]}#{m.shift}#{attr[0, 1]})#{attr[]}\n"
626
- puts m.map {|s| "#{attr[1]}#{s}#{attr[]}\n"}
627
- if attr == ATTR_PLAIN
628
- puts messages
629
- unless lasts.empty?
630
- puts lasts
631
- printf "... %d levels...\n", levels if levels > 0
632
- end
631
+ message = convert_invalid_byte_sequence(message)
632
+ message = message.gsub(/((?:^\t.+$\n)+)/) { |m|
633
+ case order
634
+ when :top
635
+ lines = m.split("\n")
636
+ when :bottom
637
+ lines = m.split("\n").reverse
638
+ end
639
+ unless irb_bug
640
+ lines = lines.map { |l| @context.workspace.filter_backtrace(l) }.compact
641
+ if lines.size > @context.back_trace_limit
642
+ omit = lines.size - @context.back_trace_limit
643
+ lines = lines[0..(@context.back_trace_limit - 1)]
644
+ lines << "\t... %d levels..." % omit
645
+ end
646
+ end
647
+ lines = lines.reverse if order == :bottom
648
+ lines.map{ |l| l + "\n" }.join
649
+ }
650
+ puts message
633
651
  end
634
652
  print "Maybe IRB bug!\n" if irb_bug
635
653
  end
@@ -60,6 +60,10 @@ module IRB # :nodoc:
60
60
  on_words_beg: [[RED, BOLD], ALL],
61
61
  on_parse_error: [[RED, REVERSE], ALL],
62
62
  compile_error: [[RED, REVERSE], ALL],
63
+ on_assign_error: [[RED, REVERSE], ALL],
64
+ on_alias_error: [[RED, REVERSE], ALL],
65
+ on_class_name_error:[[RED, REVERSE], ALL],
66
+ on_param_error: [[RED, REVERSE], ALL],
63
67
  }
64
68
  rescue NameError
65
69
  # Give up highlighting Ripper-incompatible older Ruby
@@ -67,6 +71,9 @@ module IRB # :nodoc:
67
71
  end
68
72
  private_constant :TOKEN_SEQ_EXPRS
69
73
 
74
+ ERROR_TOKENS = TOKEN_SEQ_EXPRS.keys.select { |k| k.to_s.end_with?('error') }
75
+ private_constant :ERROR_TOKENS
76
+
70
77
  class << self
71
78
  def colorable?
72
79
  $stdout.tty? && supported? && (/mswin|mingw/ =~ RUBY_PLATFORM || (ENV.key?('TERM') && ENV['TERM'] != 'dumb'))
@@ -107,7 +114,7 @@ module IRB # :nodoc:
107
114
  # If `complete` is false (code is incomplete), this does not warn compile_error.
108
115
  # This option is needed to avoid warning a user when the compile_error is happening
109
116
  # because the input is not wrong but just incomplete.
110
- def colorize_code(code, complete: true)
117
+ def colorize_code(code, complete: true, ignore_error: false)
111
118
  return code unless colorable?
112
119
 
113
120
  symbol_state = SymbolState.new
@@ -115,6 +122,11 @@ module IRB # :nodoc:
115
122
  length = 0
116
123
 
117
124
  scan(code, allow_last_error: !complete) do |token, str, expr|
125
+ # IRB::ColorPrinter skips colorizing fragments with any invalid token
126
+ if ignore_error && ERROR_TOKENS.include?(token)
127
+ return Reline::Unicode.escape_for_print(code)
128
+ end
129
+
118
130
  in_symbol = symbol_state.scan_token(token)
119
131
  str.each_line do |line|
120
132
  line = Reline::Unicode.escape_for_print(line)
@@ -180,11 +192,12 @@ module IRB # :nodoc:
180
192
  end
181
193
  end
182
194
  end
195
+ ensure
183
196
  $VERBOSE = verbose
184
197
  end
185
198
 
186
199
  def dispatch_seq(token, expr, str, in_symbol:)
187
- if token == :on_parse_error or token == :compile_error
200
+ if ERROR_TOKENS.include?(token)
188
201
  TOKEN_SEQ_EXPRS[token][0]
189
202
  elsif in_symbol
190
203
  [YELLOW]
@@ -0,0 +1,28 @@
1
+ # frozen_string_literal: true
2
+ require 'pp'
3
+ require 'irb/color'
4
+
5
+ module IRB
6
+ class ColorPrinter < ::PP
7
+ def self.pp(obj, out = $>, width = 79)
8
+ q = ColorPrinter.new(out, width)
9
+ q.guard_inspect_key {q.pp obj}
10
+ q.flush
11
+ out << "\n"
12
+ end
13
+
14
+ def text(str, width = nil)
15
+ unless str.is_a?(String)
16
+ str = str.inspect
17
+ end
18
+ width ||= str.length
19
+
20
+ case str
21
+ when /\A#</, '=', '>'
22
+ super(Color.colorize(str, [:GREEN]), width)
23
+ else
24
+ super(Color.colorize_code(str, ignore_error: true), width)
25
+ end
26
+ end
27
+ end
28
+ end
@@ -47,7 +47,7 @@ module IRB
47
47
  when /^((["'`]).*\2)\.([^.]*)$/
48
48
  # String
49
49
  receiver = $1
50
- message = Regexp.quote($3)
50
+ message = $3
51
51
 
52
52
  candidates = String.instance_methods.collect{|m| m.to_s}
53
53
  if doc_namespace
@@ -59,7 +59,7 @@ module IRB
59
59
  when /^(\/[^\/]*\/)\.([^.]*)$/
60
60
  # Regexp
61
61
  receiver = $1
62
- message = Regexp.quote($2)
62
+ message = $2
63
63
 
64
64
  candidates = Regexp.instance_methods.collect{|m| m.to_s}
65
65
  if doc_namespace
@@ -71,7 +71,7 @@ module IRB
71
71
  when /^([^\]]*\])\.([^.]*)$/
72
72
  # Array
73
73
  receiver = $1
74
- message = Regexp.quote($2)
74
+ message = $2
75
75
 
76
76
  candidates = Array.instance_methods.collect{|m| m.to_s}
77
77
  if doc_namespace
@@ -83,7 +83,7 @@ module IRB
83
83
  when /^([^\}]*\})\.([^.]*)$/
84
84
  # Proc or Hash
85
85
  receiver = $1
86
- message = Regexp.quote($2)
86
+ message = $2
87
87
 
88
88
  proc_candidates = Proc.instance_methods.collect{|m| m.to_s}
89
89
  hash_candidates = Hash.instance_methods.collect{|m| m.to_s}
@@ -117,7 +117,7 @@ module IRB
117
117
  when /^([A-Z].*)::([^:.]*)$/
118
118
  # Constant or class methods
119
119
  receiver = $1
120
- message = Regexp.quote($2)
120
+ message = $2
121
121
  begin
122
122
  candidates = eval("#{receiver}.constants.collect{|m| m.to_s}", bind)
123
123
  candidates |= eval("#{receiver}.methods.collect{|m| m.to_s}", bind)
@@ -134,7 +134,7 @@ module IRB
134
134
  # Symbol
135
135
  receiver = $1
136
136
  sep = $2
137
- message = Regexp.quote($3)
137
+ message = $3
138
138
 
139
139
  candidates = Symbol.instance_methods.collect{|m| m.to_s}
140
140
  if doc_namespace
@@ -147,7 +147,7 @@ module IRB
147
147
  # Numeric
148
148
  receiver = $~[:num]
149
149
  sep = $~[:sep]
150
- message = Regexp.quote($~[:mes])
150
+ message = $~[:mes]
151
151
 
152
152
  begin
153
153
  instance = eval(receiver, bind)
@@ -169,7 +169,7 @@ module IRB
169
169
  # Numeric(0xFFFF)
170
170
  receiver = $1
171
171
  sep = $2
172
- message = Regexp.quote($3)
172
+ message = $3
173
173
 
174
174
  begin
175
175
  instance = eval(receiver, bind)
@@ -201,7 +201,7 @@ module IRB
201
201
  # variable.func or func.func
202
202
  receiver = $1
203
203
  sep = $2
204
- message = Regexp.quote($3)
204
+ message = $3
205
205
 
206
206
  gv = eval("global_variables", bind).collect{|m| m.to_s}.push("true", "false", "nil")
207
207
  lv = eval("local_variables", bind).collect{|m| m.to_s}
@@ -244,7 +244,7 @@ module IRB
244
244
  # unknown(maybe String)
245
245
 
246
246
  receiver = ""
247
- message = Regexp.quote($1)
247
+ message = $1
248
248
 
249
249
  candidates = String.instance_methods(true).collect{|m| m.to_s}
250
250
  if doc_namespace
@@ -294,7 +294,7 @@ module IRB
294
294
  Operators = %w[% & * ** + - / < << <= <=> == === =~ > >= >> [] []= ^ ! != !~]
295
295
 
296
296
  def self.select_message(receiver, message, candidates, sep = ".")
297
- candidates.grep(/^#{message}/).collect do |e|
297
+ candidates.grep(/^#{Regexp.quote(message)}/).collect do |e|
298
298
  case e
299
299
  when /^[a-zA-Z_]/
300
300
  receiver + sep + e
@@ -100,29 +100,27 @@ module IRB # :nodoc:
100
100
  # Proc to call when the input is evaluated and output in irb.
101
101
  def inspect_value(v)
102
102
  @inspect.call(v)
103
+ rescue
104
+ puts "(Object doesn't support #inspect)"
105
+ ''
103
106
  end
104
107
  end
105
108
 
106
109
  Inspector.def_inspector([false, :to_s, :raw]){|v| v.to_s}
107
- Inspector.def_inspector([true, :p, :inspect]){|v|
108
- begin
109
- result = v.inspect
110
- if IRB.conf[:MAIN_CONTEXT]&.use_colorize? && Color.inspect_colorable?(v)
111
- result = Color.colorize_code(result)
112
- end
113
- result
114
- rescue NoMethodError
115
- puts "(Object doesn't support #inspect)"
116
- ''
117
- end
118
- }
119
- Inspector.def_inspector([:pp, :pretty_inspect], proc{require "pp"}){|v|
120
- result = v.pretty_inspect.chomp
110
+ Inspector.def_inspector([:p, :inspect]){|v|
111
+ result = v.inspect
121
112
  if IRB.conf[:MAIN_CONTEXT]&.use_colorize? && Color.inspect_colorable?(v)
122
113
  result = Color.colorize_code(result)
123
114
  end
124
115
  result
125
116
  }
117
+ Inspector.def_inspector([true, :pp, :pretty_inspect], proc{require "irb/color_printer"}){|v|
118
+ if IRB.conf[:MAIN_CONTEXT]&.use_colorize?
119
+ IRB::ColorPrinter.pp(v, '').chomp
120
+ else
121
+ v.pretty_inspect.chomp
122
+ end
123
+ }
126
124
  Inspector.def_inspector([:yaml, :YAML], proc{require "yaml"}){|v|
127
125
  begin
128
126
  YAML.dump(v)
@@ -106,24 +106,72 @@ class RubyLex
106
106
  end
107
107
  end
108
108
 
109
+ ERROR_TOKENS = [
110
+ :on_parse_error,
111
+ :compile_error,
112
+ :on_assign_error,
113
+ :on_alias_error,
114
+ :on_class_name_error,
115
+ :on_param_error
116
+ ]
117
+
109
118
  def ripper_lex_without_warning(code)
110
119
  verbose, $VERBOSE = $VERBOSE, nil
111
120
  tokens = nil
112
121
  self.class.compile_with_errors_suppressed(code) do |inner_code, line_no|
113
- tokens = Ripper.lex(inner_code, '-', line_no)
122
+ lexer = Ripper::Lexer.new(inner_code, '-', line_no)
123
+ if lexer.respond_to?(:scan) # Ruby 2.7+
124
+ tokens = []
125
+ pos_to_index = {}
126
+ lexer.scan.each do |t|
127
+ if pos_to_index.has_key?(t[0])
128
+ index = pos_to_index[t[0]]
129
+ found_tk = tokens[index]
130
+ if ERROR_TOKENS.include?(found_tk[1]) && !ERROR_TOKENS.include?(t[1])
131
+ tokens[index] = t
132
+ end
133
+ else
134
+ pos_to_index[t[0]] = tokens.size
135
+ tokens << t
136
+ end
137
+ end
138
+ else
139
+ tokens = lexer.parse
140
+ end
114
141
  end
115
- $VERBOSE = verbose
116
142
  tokens
143
+ ensure
144
+ $VERBOSE = verbose
145
+ end
146
+
147
+ def find_prev_spaces(line_index)
148
+ return 0 if @tokens.size == 0
149
+ md = @tokens[0][2].match(/(\A +)/)
150
+ prev_spaces = md.nil? ? 0 : md[1].count(' ')
151
+ line_count = 0
152
+ @tokens.each_with_index do |t, i|
153
+ if t[2].include?("\n")
154
+ line_count += t[2].count("\n")
155
+ if line_count >= line_index
156
+ return prev_spaces
157
+ end
158
+ if (@tokens.size - 1) > i
159
+ md = @tokens[i + 1][2].match(/(\A +)/)
160
+ prev_spaces = md.nil? ? 0 : md[1].count(' ')
161
+ end
162
+ end
163
+ end
164
+ prev_spaces
117
165
  end
118
166
 
119
167
  def set_auto_indent(context)
120
168
  if @io.respond_to?(:auto_indent) and context.auto_indent_mode
121
169
  @io.auto_indent do |lines, line_index, byte_pointer, is_newline|
122
170
  if is_newline
123
- md = lines[line_index - 1].match(/(\A +)/)
124
- prev_spaces = md.nil? ? 0 : md[1].count(' ')
125
171
  @tokens = ripper_lex_without_warning(lines[0..line_index].join("\n"))
172
+ prev_spaces = find_prev_spaces(line_index)
126
173
  depth_difference = check_newline_depth_difference
174
+ depth_difference = 0 if depth_difference < 0
127
175
  prev_spaces + depth_difference * 2
128
176
  else
129
177
  code = line_index.zero? ? '' : lines[0..(line_index - 1)].map{ |l| l + "\n" }.join
@@ -360,14 +408,8 @@ class RubyLex
360
408
  next if index > 0 and tokens[index - 1][3].allbits?(Ripper::EXPR_FNAME)
361
409
  case t[2]
362
410
  when 'do'
363
- if index > 0 and tokens[index - 1][3].anybits?(Ripper::EXPR_CMDARG | Ripper::EXPR_ENDFN | Ripper::EXPR_ARG)
364
- # method_with_block do; end
365
- indent += 1
366
- else
367
- # while cond do; end # also "until" or "for"
368
- # This "do" doesn't increment indent because "while" already
369
- # incremented.
370
- end
411
+ syntax_of_do = take_corresponding_syntax_to_kw_do(tokens, index)
412
+ indent += 1 if syntax_of_do == :method_calling
371
413
  when 'def', 'case', 'for', 'begin', 'class', 'module'
372
414
  indent += 1
373
415
  when 'if', 'unless', 'while', 'until'
@@ -382,6 +424,40 @@ class RubyLex
382
424
  indent
383
425
  end
384
426
 
427
+ def take_corresponding_syntax_to_kw_do(tokens, index)
428
+ syntax_of_do = nil
429
+ # Finding a syntax correnponding to "do".
430
+ index.downto(0) do |i|
431
+ tk = tokens[i]
432
+ # In "continue", the token isn't the corresponding syntax to "do".
433
+ #is_continue = process_continue(@tokens[0..(i - 1)])
434
+ # continue ではなく、直前に (:on_ignored_nl|:on_nl|:on_comment):on_sp* みたいなのがあるかどうかを調べる
435
+ non_sp_index = tokens[0..(i - 1)].rindex{ |t| t[1] != :on_sp }
436
+ first_in_fomula = false
437
+ if non_sp_index.nil?
438
+ first_in_fomula = true
439
+ elsif [:on_ignored_nl, :on_nl, :on_comment].include?(tokens[non_sp_index][1])
440
+ first_in_fomula = true
441
+ end
442
+ if tk[3].anybits?(Ripper::EXPR_CMDARG) and tk[1] == :on_ident
443
+ # The target method call to pass the block with "do".
444
+ syntax_of_do = :method_calling
445
+ break if first_in_fomula
446
+ elsif tk[1] == :on_kw && %w{while until for}.include?(tk[2])
447
+ # A loop syntax in front of "do" found.
448
+ #
449
+ # while cond do # also "until" or "for"
450
+ # end
451
+ #
452
+ # This "do" doesn't increment indent because the loop syntax already
453
+ # incremented.
454
+ syntax_of_do = :loop_syntax
455
+ break if first_in_fomula
456
+ end
457
+ end
458
+ syntax_of_do
459
+ end
460
+
385
461
  def check_newline_depth_difference
386
462
  depth_difference = 0
387
463
  open_brace_on_line = 0
@@ -410,7 +486,7 @@ class RubyLex
410
486
 
411
487
  case t[1]
412
488
  when :on_ignored_nl, :on_nl, :on_comment
413
- if index != (@tokens.size - 1)
489
+ if index != (@tokens.size - 1) and in_oneliner_def != :BODY
414
490
  depth_difference = 0
415
491
  open_brace_on_line = 0
416
492
  end
@@ -428,14 +504,8 @@ class RubyLex
428
504
  next if index > 0 and @tokens[index - 1][3].allbits?(Ripper::EXPR_FNAME)
429
505
  case t[2]
430
506
  when 'do'
431
- if index > 0 and @tokens[index - 1][3].anybits?(Ripper::EXPR_CMDARG | Ripper::EXPR_ENDFN | Ripper::EXPR_ARG)
432
- # method_with_block do; end
433
- depth_difference += 1
434
- else
435
- # while cond do; end # also "until" or "for"
436
- # This "do" doesn't increment indent because "while" already
437
- # incremented.
438
- end
507
+ syntax_of_do = take_corresponding_syntax_to_kw_do(@tokens, index)
508
+ depth_difference += 1 if syntax_of_do == :method_calling
439
509
  when 'def', 'case', 'for', 'begin', 'class', 'module'
440
510
  depth_difference += 1
441
511
  when 'if', 'unless', 'while', 'until', 'rescue'
@@ -445,6 +515,8 @@ class RubyLex
445
515
  end
446
516
  when 'else', 'elsif', 'ensure', 'when', 'in'
447
517
  depth_difference += 1
518
+ when 'end'
519
+ depth_difference -= 1
448
520
  end
449
521
  end
450
522
  end
@@ -488,11 +560,13 @@ class RubyLex
488
560
 
489
561
  case t[1]
490
562
  when :on_ignored_nl, :on_nl, :on_comment
491
- corresponding_token_depth = nil
492
- spaces_at_line_head = 0
493
- is_first_spaces_of_line = true
494
- is_first_printable_of_line = true
495
- open_brace_on_line = 0
563
+ if in_oneliner_def != :BODY
564
+ corresponding_token_depth = nil
565
+ spaces_at_line_head = 0
566
+ is_first_spaces_of_line = true
567
+ is_first_printable_of_line = true
568
+ open_brace_on_line = 0
569
+ end
496
570
  next
497
571
  when :on_sp
498
572
  spaces_at_line_head = t[2].count(' ') if is_first_spaces_of_line
@@ -514,7 +588,12 @@ class RubyLex
514
588
  when :on_kw
515
589
  next if index > 0 and @tokens[index - 1][3].allbits?(Ripper::EXPR_FNAME)
516
590
  case t[2]
517
- when 'def', 'do', 'case', 'for', 'begin', 'class', 'module'
591
+ when 'do'
592
+ syntax_of_do = take_corresponding_syntax_to_kw_do(@tokens, index)
593
+ if syntax_of_do == :method_calling
594
+ spaces_of_nest.push(spaces_at_line_head)
595
+ end
596
+ when 'def', 'case', 'for', 'begin', 'class', 'module'
518
597
  spaces_of_nest.push(spaces_at_line_head)
519
598
  when 'rescue'
520
599
  unless t[3].allbits?(Ripper::EXPR_LABEL)
@@ -11,7 +11,7 @@
11
11
  #
12
12
 
13
13
  module IRB # :nodoc:
14
- VERSION = "1.3.0"
14
+ VERSION = "1.3.1"
15
15
  @RELEASE_VERSION = VERSION
16
- @LAST_UPDATE_DATE = "2020-12-25"
16
+ @LAST_UPDATE_DATE = "2021-01-12"
17
17
  end
metadata CHANGED
@@ -1,14 +1,14 @@
1
1
  --- !ruby/object:Gem::Specification
2
2
  name: irb
3
3
  version: !ruby/object:Gem::Version
4
- version: 1.3.0
4
+ version: 1.3.1
5
5
  platform: ruby
6
6
  authors:
7
7
  - Keiju ISHITSUKA
8
8
  autorequire:
9
9
  bindir: exe
10
10
  cert_chain: []
11
- date: 2020-12-24 00:00:00.000000000 Z
11
+ date: 2021-01-11 00:00:00.000000000 Z
12
12
  dependencies:
13
13
  - !ruby/object:Gem::Dependency
14
14
  name: reline
@@ -81,6 +81,7 @@ files:
81
81
  - lib/irb/cmd/pushws.rb
82
82
  - lib/irb/cmd/subirb.rb
83
83
  - lib/irb/color.rb
84
+ - lib/irb/color_printer.rb
84
85
  - lib/irb/completion.rb
85
86
  - lib/irb/context.rb
86
87
  - lib/irb/easter-egg.rb
@@ -135,7 +136,7 @@ required_rubygems_version: !ruby/object:Gem::Requirement
135
136
  - !ruby/object:Gem::Version
136
137
  version: '0'
137
138
  requirements: []
138
- rubygems_version: 3.1.4
139
+ rubygems_version: 3.2.3
139
140
  signing_key:
140
141
  specification_version: 4
141
142
  summary: Interactive Ruby command-line tool for REPL (Read Eval Print Loop).