diff options
author | tomoya ishida <[email protected]> | 2022-10-18 14:44:04 +0900 |
---|---|---|
committer | git <[email protected]> | 2022-10-18 05:44:07 +0000 |
commit | a09f764ce52838a363b006ea434287eca431dbae (patch) | |
tree | 8da2c8147cb80ea8caf9484bdf7a1d5915e30b06 /lib/irb/input-method.rb | |
parent | 344e6c915f41d99df024c7e90403baca0d5213a5 (diff) |
[ruby/irb] Always use local variables in current context to parse code (https://github.com/ruby/irb/pull/397)
* Use local_variables for colorize, code_block_open check, nesting_level and assignment_expression check
* Check if expression is an assignment BEFORE evaluating it. evaluate might define new localvars and change result of assignment_expression?
* Add local_variables dependent code test
* pend local variable dependent test on truffleruby
code_block_open is not working on truffleruby
* Always pass context to RubyLex#lex
* Rename local_variable_assign_code generator method name
* Add assignment expression truncate test
* Add Context#local_variables and make generate_local_variables_assign_code more simple
* Update lib/irb/input-method.rb
Co-authored-by: Stan Lo <[email protected]>
* Add a comment why assignment expression check should be done before evaluate
https://github.com/ruby/irb/commit/c8b3877281
Co-authored-by: Stan Lo <[email protected]>
Co-authored-by: Takashi Kokubun <[email protected]>
Diffstat (limited to 'lib/irb/input-method.rb')
-rw-r--r-- | lib/irb/input-method.rb | 3 |
1 files changed, 2 insertions, 1 deletions
diff --git a/lib/irb/input-method.rb b/lib/irb/input-method.rb index aa5cb5adb9..b0110dd09b 100644 --- a/lib/irb/input-method.rb +++ b/lib/irb/input-method.rb @@ -286,7 +286,8 @@ module IRB if IRB.conf[:USE_COLORIZE] proc do |output, complete: | next unless IRB::Color.colorable? - IRB::Color.colorize_code(output, complete: complete) + lvars = IRB.CurrentContext&.local_variables || [] + IRB::Color.colorize_code(output, complete: complete, local_variables: lvars) end else proc do |output| |