diff options
author | Schneems <[email protected]> | 2024-11-14 18:54:46 -0600 |
---|---|---|
committer | git <[email protected]> | 2024-11-15 01:31:26 +0000 |
commit | 226cfda3069c76c094d294a68585b5772fcc730a (patch) | |
tree | 8de78ddbce11b56d96703d0055c4894ddf4fea41 /lib/syntax_suggest/api.rb | |
parent | 51666c827b5aa9289113699670cbd6910ea2b3b1 (diff) |
[ruby/syntax_suggest] Fix missing line break due to puts logic
In #225 it was reported that the output looks incorrect:
```
$ cat /tmp/4a71c7e417cc9eac0971e3a2519b295c/scratch.rb
def x.y.z
end
$ ruby /tmp/4a71c7e417cc9eac0971e3a2519b295c/scratch.rb
/tmp/4a71c7e417cc9eac0971e3a2519b295c/scratch.rb: --> /tmp/4a71c7e417cc9eac0971e3a2519b295c/scratch.rb
expected a delimiter to close the parametersunexpected '.', ignoring it
> 1 def x.y.z
> 2 end
```
Specifically:
```
expected a delimiter to close the parametersunexpected '.', ignoring it
```
However this does not show up when executing the debug executable:
```
$ bin/bundle exec exe/syntax_suggest /tmp/4a71c7e417cc9eac0971e3a2519b295c/scratch.rb
--> /tmp/4a71c7e417cc9eac0971e3a2519b295c/scratch.rb
expected a delimiter to close the parameters
unexpected '.', ignoring it
> 1 def x.y.z
> 2 end
```
This is because `exe/syntax_suggest` uses STDOUT.puts while calling `ruby` with the filename uses a fake IO object represented by MiniStringIO. This class was incorrectly not adding a newline to the end of the print.
The fix was to move the class to it's own file where it can be tested and then fix the behavior.
close https://github.com/ruby/syntax_suggest/pull/225
https://github.com/ruby/syntax_suggest/commit/d2ecd94a3b
Co-authored-by: Andy Yong <[email protected]>
Diffstat (limited to 'lib/syntax_suggest/api.rb')
-rw-r--r-- | lib/syntax_suggest/api.rb | 1 |
1 files changed, 1 insertions, 0 deletions
diff --git a/lib/syntax_suggest/api.rb b/lib/syntax_suggest/api.rb index 65660ec5e5..46c9c8adac 100644 --- a/lib/syntax_suggest/api.rb +++ b/lib/syntax_suggest/api.rb @@ -227,6 +227,7 @@ require_relative "lex_all" require_relative "code_line" require_relative "code_block" require_relative "block_expand" +require_relative "mini_stringio" require_relative "priority_queue" require_relative "unvisited_lines" require_relative "around_block_scan" |