diff options
author | aycabta <aycabta@gmail.com> | 2019-06-18 21:56:41 +0900 |
---|---|---|
committer | aycabta <aycabta@gmail.com> | 2019-06-18 21:58:05 +0900 |
commit | 84903b31c87b98083cec406745dc7e3088ba643b (patch) | |
tree | ce5e34a71c883c1914a6b5267d581ce56a92759c /lib | |
parent | 32e65e9e5adbfb8b3d67e0ec0865a3f90d2e82dd (diff) | |
download | ruby-84903b31c87b98083cec406745dc7e3088ba643b.tar.gz |
Fix auto indent crash when blank input
Diffstat (limited to 'lib')
-rw-r--r-- | lib/irb/ruby-lex.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/irb/ruby-lex.rb b/lib/irb/ruby-lex.rb index 036b831591..ad3a285f02 100644 --- a/lib/irb/ruby-lex.rb +++ b/lib/irb/ruby-lex.rb @@ -70,7 +70,8 @@ class RubyLex prev_spaces + (indent - prev_indent) * 2 else code = line_index.zero? ? '' : lines[0..(line_index - 1)].map{ |l| l + "\n" }.join - code += lines[line_index].byteslice(0, byte_pointer) + last_line = lines[line_index]&.byteslice(0, byte_pointer) + code += last_line if last_line @tokens = Ripper.lex(code) indent, close_token = process_nesting_level(check_closing: true) if close_token |