Nobuhiro IMAI
b0fb208218
[ruby/irb] follow up the actual line number
...
7aed8fe3b1
2021-02-03 00:09:32 +09:00
Nobuhiro IMAI
e80e5a2f89
[ruby/irb] use RubyLex::TerminateLineInput
appropriately [Bug #17564 ]
...
* using the appropriciate exception instead of `break` so that the session
can be continue after the `irb_source` and `irb_load` commands
* suppress extra new line due to one more `#prompt` call
bdefaa7cfd
2021-01-27 15:02:05 +09:00
aycabta
743c44ee21
[ruby/irb] Indent correctly with method calling with receiver
...
e7c68e74a0
2021-01-24 14:35:34 +09:00
aycabta
fc54af8aa1
[ruby/irb] Indent correctly with keyword "for" and "in"
...
47c83ea724
2021-01-24 14:35:26 +09:00
aycabta
fb33ec0119
[ruby/irb] Delete a doodle-level memo comment...
...
fc3e1d9e0c
2021-01-22 08:15:31 +09:00
Nobuyoshi Nakada
903af74bbd
[ruby/irb] Ensure to restore $VERBOSE
...
cef474a76a
2021-01-05 18:07:18 +09:00
aycabta
0123bc9d38
[ruby/irb] Use error tokens if there are no correct tokens in the same place
...
For example, the broken code "%www" will result in only one error token.
9fa39a7cf3
2021-01-05 18:06:43 +09:00
aycabta
5a1866caff
[ruby/irb] Use Ripper::Lexer#scan to take broken tokens
...
ref. https://github.com/ruby/reline/pull/242
54f90cb6c9
2021-01-05 18:06:34 +09:00
aycabta
505e01fe12
[ruby/irb] Heredoc may contain multiple newlines in a single token
...
Use the start token as the indentation criteria so that it works properly in
heredoc.
ref. https://github.com/ruby/reline/pull/242
9704808dfd
2021-01-05 18:06:26 +09:00
aycabta
5012512398
[ruby/irb] Handle indentations related to keyword "do" correctly
...
This fixes ruby/irb#158 .
964643400b
2021-01-05 18:06:10 +09:00
aycabta
cce72a2411
[ruby/irb] Newline in oneliner def doesn't reset indent
...
This closes ruby/irb#132 .
43456dcf5e
2021-01-05 18:04:45 +09:00
aycabta
31bd172185
[ruby/irb] Suppress "shadowing outer" warning
...
8b83fbef69
2020-12-23 21:26:25 +09:00
aycabta
841d22ea47
[ruby/reline] [ruby/irb] Handle multiple newlines in a token correctly
...
Co-authored-by: manga_osyo <manga.osyo@gmail.com>
Co-authored-by: ima1zumi <mariimaizumi5@gmail.com>
c59a9be82f
a7922da16b
2020-12-23 06:06:07 +09:00
aycabta
47b26795d0
[ruby/irb] Change variables handling for compatibility
...
26fd1a75cf
2020-12-22 23:45:43 +09:00
aycabta
8b6aaeaddf
[ruby/irb] Handle rest of tokens correctly if no newline at last
...
f3c8edad2a
2020-12-20 16:23:58 +09:00
aycabta
dc61affd67
[ruby/reline] [ruby/irb] Call ripper only once when generating dynamic prompt
...
babb122a48
e6dbcb3b42
2020-12-19 02:12:11 +09:00
Nobuyoshi Nakada
b5effe07bd
[ruby/irb] Fixed a typo in a comment [ci skip]
...
ce373417f3
2020-12-17 20:22:55 +09:00
Nobuhiro IMAI
cbf6a7f906
[ruby/irb] workaround for lack of tokens from Ripper.lex
...
* Fixes #38
905fb8e52e
2020-12-17 20:22:29 +09:00
Benoit Daloze
afb8aba4af
[ruby/irb] Add a fallback for check_code_block that does not depend on implementation-private APIs
...
* Fixes https://github.com/ruby/irb/issues/133
5eb3ef3293
2020-11-22 21:00:11 +09:00
Nobuhiro IMAI
5218f17737
[ruby/irb] support more body argument for oneliner method definition
...
2ff1295533
2020-11-22 21:00:11 +09:00
aycabta
a30dea5852
[ruby/irb] Support shortening lambda notetion for nesting level of prompt
...
f1a775af47
2020-08-18 14:38:02 +09:00
aycabta
43c648c832
[ruby/irb] Support shortening lambda notation
...
8e3f81d428
2020-08-18 14:38:02 +09:00
aycabta
5474007d61
[ruby/irb] Support oneline method definition
...
826ae909c9
2020-08-18 14:38:01 +09:00
Yusuke Endoh
098e8c2873
Suppress "assigned but unused variable" warnings
2020-07-23 23:44:25 +09:00
Nobuhiro IMAI
f6e789e3b0
[ruby/irb] handle rescue modifier properly
...
6de1341f5e
2020-07-22 02:31:47 +09:00
aycabta
c72a2fad97
[ruby/irb] Simplify RubyLex.compile_with_errors_suppressed
...
nobu-san reviewed,
https://github.com/ruby/irb/pull/106#pullrequestreview-423400033
> How about lexer = Ripper::Lexer.new(";\n#{code}", nil, 0)?
> Encoding pragma is effective only at the beginning.
> And the semicolon and newline will be skipped because the position is before
> the initial pos.
I employ the way.
Co-authored-by: Nobuyoshi Nakada <nobu@ruby-lang.org>
e593cc65b7
2020-07-22 02:31:46 +09:00
aycabta
1dfd24a7fc
[ruby/irb] Suppress incomplete encoding magic comment error
...
443e90af80
2020-07-22 02:31:46 +09:00
aycabta
78ccab2530
[ruby/irb] Suppress incomplete coding magic comment error
...
6a457edbd1
2020-07-22 02:31:46 +09:00
Charles Oliver Nutter
2b6848af0e
[ruby/irb] Require jruby lib to get JRuby.compile_ir
...
dc59afe4f6
2020-03-29 04:44:53 +09:00
aycabta
22477128cd
[ruby/irb] Suppress crashing when EncodingError has occurred without lineno
...
13572d8cdc
2020-03-26 17:41:21 +09:00
aycabta
8b8cc01229
[ruby/irb] Fix auto indent with closed brace
...
A closed brace in auto-indent shouldn't affect the next brace in the same line,
but it behaves like below:
p() {
}
It's a bug.
fbe59e344f
2020-02-12 13:14:28 +09:00
Ben
c94025b630
[ruby/irb] Fix crashing when multiple open braces per line
...
https://github.com/ruby/irb/issues/55
If we had put multiple open braces on a line the with no closing brace
spaces_of_nest array keeps getting '0' added to it. This means that when
we pop off of this array we are saying that we should be in position zero
for the next line. This is an issue because we don't always want to be
in position 0 after a closing brace.
Example:
```
[[[
]
]
]
```
In the above example the 'spaces_of_nest' array looks like this after
the first line is entered: [0,0,0]. We really want to be indented 4
spaces for the 1st closing brace 2 for the 2nd and 0 for the 3rd. i.e.
we want it to be: [0,2,4].
We also saw this issue with a heredoc inside of an array.
```
[<<FOO]
hello
FOO
```
80c69c8272
2020-01-14 15:40:38 +09:00
Ben
9994eb8a5e
[ruby/irb] Fix newline depth with multiple braces
...
This commit fixes the check_newline_depth_difference method to multiple
open braces on one line into account. Before this change we were
subtracting from the depth in check_newline_depth_difference on
every open brace. This is the right thing to do if the opening and
closing brace are on the same line. For example in a method definition we
have an opening and closing parentheses we want to add 1 to our depth,
and then remove it.
```
def foo()
end
```
However this isn't the correct behavior when the brace spans multiple
lines. If a brace spans multiple lines we don't want to subtract from
check_newline_depth_difference and we want to treat the braces the same
way as we do `end` and allow check_corresponding_token_depth to pop the
correct depth.
Example of bad behavior:
```
def foo()
[
]
puts 'bar'
end
```
Example of desired behavior:
```
def foo()
[
]
puts 'bar'
end
```
7dc8af01e0
2020-01-14 15:40:38 +09:00
Yusuke Endoh
616f1357c3
[ruby/irb] Make nesting level up for 1.times do
...
Follow up of the previous commit
ab207353d3
2019-12-22 01:57:35 +09:00
Yusuke Endoh
a3cc2a2fbd
[ruby/irb] Fix auto-indent for 1.times do
...
Fixes #47
6b8eca4635
2019-12-22 01:57:35 +09:00
aycabta
027e847cd2
Fix auto-indent behavior correctly
2019-12-03 13:02:50 +09:00
aycabta
c4686b9235
Revert "Treat :@1, :@@1, @1, and @@1 correctly to check termination"
...
This reverts commit 5e275dd2af
.
...The @1 type numberd parameter is reverted from Ruby syntax.
2019-11-29 17:38:18 +09:00
aycabta
51ea1abb5f
Remove e2mmap dependency
2019-11-25 05:38:09 +09:00
aycabta
9306602f24
Replace typo "bock" with "block"
2019-11-20 09:58:33 +09:00
aycabta
19a310b0ac
A preceding token of "do" of block has EXPR_CMDARG or EXPR_ENDFN
...
meth do # the preceding token of "do" has EXPR_CMDARG
end
meth() do # the preceding token of "do" has EXPR_ENDFN
end
2019-11-20 09:56:13 +09:00
aycabta
49b4507fd3
Number sign comment (# bla bla) is a kind of newline character
2019-11-20 08:39:43 +09:00
aycabta
a5b6d7bca8
Suppress warnings except for when last evaluation
...
Co-authored-by: Kazuhiro NISHIYAMA <zn@mbf.nifty.com>
2019-11-13 15:15:28 +09:00
aycabta
aa03de8ba1
Treat two types "do" correctly
...
A "do" what has followed a token what has EXPR_CMDARG is for a block,
and in other cases "do" is for "while", "until" or "for".
2019-08-20 08:31:02 +09:00
Charles Oliver Nutter
f9f02e8216
Use JRuby equivalent of RubyVM.compile.
...
RubyVM is specific to CRuby and not supported on JRuby. This is
the equivalent operation.
2019-07-27 16:56:04 +09:00
aycabta
7b9bb6f44a
Check code_block_open for whether code continues
2019-07-03 23:37:46 +09:00
aycabta
776759e300
Keyword token that follows EXPR_FNAME must be a method name
2019-07-02 03:34:15 +09:00
aycabta
c718f56ed9
Remove auto indent of continuation line
2019-06-28 22:25:35 +09:00
Nobuyoshi Nakada
951f80f2dd
Removed unused variable
2019-06-28 14:09:26 +09:00
aycabta
2fd03fd7e6
EXPR_LABEL also indicates non-continuation line
...
Example:
[
1, # this is not continuation line
2
]
2019-06-27 16:03:43 +09:00
aycabta
d6bcf36793
EXPR_CMDARG also indicates the end of an expression
2019-06-27 10:59:26 +09:00