From b35787c7231c40254e6878b1f535d0e4e54f49c6 Mon Sep 17 00:00:00 2001 From: Maxime Lapointe Date: Thu, 18 Nov 2021 13:09:37 -0500 Subject: [PATCH] Make sure to stop byebug if eval raised If an exception is raised using commands, this usually bypasses the usual mechanism that stops byebug, leading to a slow interpretter. This fixes that behavior by detecting that an exception is propagating out of eval and stopping byebug --- lib/pry-byebug/pry_ext.rb | 13 +++++++++++++ 1 file changed, 13 insertions(+) diff --git a/lib/pry-byebug/pry_ext.rb b/lib/pry-byebug/pry_ext.rb index 03c34001..b7196012 100644 --- a/lib/pry-byebug/pry_ext.rb +++ b/lib/pry-byebug/pry_ext.rb @@ -16,3 +16,16 @@ def start_with_pry_byebug(target = TOPLEVEL_BINDING, options = {}) alias start start_with_pry_byebug end + +class Pry + alias eval_without_pry_byebug eval + + def eval_with_pry_byebug(line, options = {}) + eval_without_pry_byebug(line, options) + rescue Exception + ::Byebug.stop if ::Byebug.stoppable? + raise + end + + alias eval eval_with_pry_byebug +end