mirror of
https://github.com/ruby/ruby.git
synced 2025-08-15 13:39:04 +02:00
[ruby/yarp] Match EOF after newline behavior
in Ripper EOL after whitespace is returned as a on_nl node with the whitespace as the content
be16d1deed
This commit is contained in:
parent
774845284f
commit
9aca3528aa
2 changed files with 26 additions and 0 deletions
|
@ -630,6 +630,14 @@ module YARP
|
||||||
end
|
end
|
||||||
|
|
||||||
Token.new([[lineno, column], event, value, lex_state])
|
Token.new([[lineno, column], event, value, lex_state])
|
||||||
|
|
||||||
|
when :on_eof
|
||||||
|
prev_token = result_value[index-1][0]
|
||||||
|
if prev_token.type == :COMMENT && prev_token.location.end_offset < token.location.start_offset
|
||||||
|
tokens << Token.new([[lineno, 0], :on_nl, source.byteslice(result_value[index-1].first.location.end_offset...token.location.start_offset), lex_state])
|
||||||
|
end
|
||||||
|
|
||||||
|
Token.new([[lineno, column], event, value, lex_state])
|
||||||
else
|
else
|
||||||
Token.new([[lineno, column], event, value, lex_state])
|
Token.new([[lineno, column], event, value, lex_state])
|
||||||
end
|
end
|
||||||
|
|
18
test/snapshots/indented_file_end.txt
Normal file
18
test/snapshots/indented_file_end.txt
Normal file
|
@ -0,0 +1,18 @@
|
||||||
|
ProgramNode(4...23)(
|
||||||
|
[],
|
||||||
|
StatementsNode(4...23)(
|
||||||
|
[DefNode(4...23)(
|
||||||
|
(8...10),
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
[],
|
||||||
|
(4...7),
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
nil,
|
||||||
|
(20...23)
|
||||||
|
)]
|
||||||
|
)
|
||||||
|
)
|
Loading…
Add table
Add a link
Reference in a new issue