irb
irb copied to clipboard
Fallback to non-colored inspect when coloring takes too long
Inspecting large objects may take a long time since IRB colors the entire output of #inspect all at once.
This patch lets IRB to give up coloring after a certain time and fall back to non-colored output.
Changes can be observed by inspecting large Arrays, for example [1] * 1000000.
The default timeout is 2 seconds, but this can be configured through IRB.conf[:INSPECT_COLORING_TIMEOUT].
Passing nil to this option will disable timeouts (IRB will never fall back to non-colored output).
Thanks for the PR 👍
However, it will not be the best solution to the problem because using timeout will cause hanging problems with debug for the irb:rdbg integration. See https://github.com/ruby/debug/issues/877
Maybe we should improve colour printer instead?