Skip to content

Conversation

@tompng
Copy link
Member

@tompng tompng commented Jan 14, 2023

In master, it seems that test_yamatanooroti fails.

% bundle exec ruby -Ilib test/reline/yamatanooroti/multiline_repl
Multiline REPL.
/Users/tomoya/.rbenv/versions/3.2.0/lib/ruby/gems/3.2.0/bundler/gems/irb-5c8d3df2df3c/lib/irb/ruby-lex.rb:19:in `initialize': wrong number of arguments (given 0, expected 1) (ArgumentError)
	from test/reline/yamatanooroti/multiline_repl:197:in `new'
	from test/reline/yamatanooroti/multiline_repl:197:in `<main>'

class TerminationChecker < RubyLex now needs context in constructor and multiline_repl does not work now.
I'm also opening a pull request in irb (ruby/irb#500) that deletes RubyLex#process_nesting_level and RubyLex#process_literal_type and it will also breaks reline's test.
I think multiline_repl don't need to depend on RubyLex.

I implement simple TerminationChecker.terminated? and AutoIndent#calculate_indent that only looks if def end, brackets and parenthesis.

I also find that ruby -Ilib test/reline/yamatanooroti/multiline_repl --auto-indent was not working, no indent was applied.

opt.on('--auto-indent') {
  AutoIndent.new # makes an instance of AutoIndent but doing nothing
}
% bundle exec ruby -Ilib test/reline/yamatanooroti/multiline_repl --auto-indent
Multiline REPL.
prompt> if 1
prompt> if 2
prompt> end
prompt> end
=> nil
↓
% bundle exec ruby -Ilib test/reline/yamatanooroti/multiline_repl --auto-indent
Multiline REPL.
prompt> if 1
prompt>   if 1
prompt>   end
prompt> end
=> nil

@tompng
Copy link
Member Author

tompng commented Jan 14, 2023

Test failed but I think it's a random failure

<"Multiline REPL.\n" + "prompt> def hoge\n" + "prompt>   0123456789\n"> expected but was
<"Multiline REPL.\n" + "prompt> def hog^N\n" + "prompt>   0123456789\n">

Test passed in my forked repository
https://github.com/tompng/reline/actions/runs/3918425875

@tompng tompng mentioned this pull request Jan 14, 2023
@tompng tompng force-pushed the multiline_prompt_without_rubylex branch from 22106be to fbad19e Compare January 14, 2023 21:25
@tompng tompng marked this pull request as draft January 14, 2023 22:12
@tompng tompng force-pushed the multiline_prompt_without_rubylex branch from fbad19e to 810598e Compare January 14, 2023 22:34
@tompng tompng marked this pull request as ready for review January 14, 2023 22:40
@hasumikin
Copy link
Collaborator

Nice one👍

@hasumikin hasumikin merged commit 299ba84 into ruby:master Jan 18, 2023
matzbot pushed a commit to ruby/ruby that referenced this pull request Jan 18, 2023
(ruby/reline#502)

* multiline_repl do not need to depend on RubyLex

* Add auto indent test
@tompng tompng deleted the multiline_prompt_without_rubylex branch January 18, 2023 08:56
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants