Skip to content

Commit 1639dd4

Browse files
authored
Prevent debugger from printing to STDOUT (#1968)
1 parent 7d917f0 commit 1639dd4

File tree

1 file changed

+6
-2
lines changed

1 file changed

+6
-2
lines changed

exe/ruby-lsp

Lines changed: 6 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -75,14 +75,18 @@ require "ruby_lsp/internal"
7575

7676
if options[:debug]
7777
if ["x64-mingw-ucrt", "x64-mingw32"].include?(RUBY_PLATFORM)
78-
puts "Debugging is not supported on Windows"
78+
$stderr.puts "Debugging is not supported on Windows"
7979
exit 1
8080
end
8181

8282
begin
83+
original_stdout = $stdout
84+
$stdout = $stderr
8385
require "debug/open_nonstop"
8486
rescue LoadError
85-
warn("You need to install the debug gem to use the --debug flag")
87+
$stderr.puts("You need to install the debug gem to use the --debug flag")
88+
ensure
89+
$stdout = original_stdout
8690
end
8791
end
8892

0 commit comments

Comments
 (0)