File tree Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Expand file tree Collapse file tree 1 file changed +6
-1
lines changed Original file line number Diff line number Diff line change @@ -574,6 +574,11 @@ def result
574
574
result = YARP . lex ( source , @filepath )
575
575
result_value = result . value
576
576
previous_state = nil
577
+
578
+ # In previous versions of Ruby, Ripper wouldn't flush the bom before the
579
+ # first token, so we had to have a hack in place to account for that. This
580
+ # checks for that behavior.
581
+ bom_flushed = Ripper . lex ( "\xEF \xBB \xBF # test" ) [ 0 ] [ 0 ] [ 1 ] == 0
577
582
bom = source . byteslice ( 0 ..2 ) == "\xEF \xBB \xBF "
578
583
579
584
result_value . each_with_index do |( token , lex_state ) , index |
@@ -588,7 +593,7 @@ def result
588
593
if bom && lineno == 1
589
594
column -= 3
590
595
591
- if index == 0 && column == 0
596
+ if index == 0 && column == 0 && ! bom_flushed
592
597
flushed =
593
598
case token . type
594
599
when :BACK_REFERENCE , :INSTANCE_VARIABLE , :CLASS_VARIABLE ,
You can’t perform that action at this time.
0 commit comments