Skip to content

Commit

Permalink
Prevent debugger from printing to STDOUT (#1968)
Browse files Browse the repository at this point in the history
  • Loading branch information
vinistock authored Apr 25, 2024
1 parent 7d917f0 commit 1639dd4
Showing 1 changed file with 6 additions and 2 deletions.
8 changes: 6 additions & 2 deletions exe/ruby-lsp
Original file line number Diff line number Diff line change
Expand Up @@ -75,14 +75,18 @@ require "ruby_lsp/internal"

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

begin
original_stdout = $stdout
$stdout = $stderr
require "debug/open_nonstop"
rescue LoadError
warn("You need to install the debug gem to use the --debug flag")
$stderr.puts("You need to install the debug gem to use the --debug flag")
ensure
$stdout = original_stdout
end
end

Expand Down

0 comments on commit 1639dd4

Please sign in to comment.