nonsequitur / inf-ruby

219 stars 68 forks source link

No output if region sent is selected using expand-region #187

Closed x3qt closed 4 months ago

x3qt commented 4 months ago

Hello!

Recently I've started using expand-region with inf-ruby and noticed that output is not shown despite region being successfully evaluated: image

My only assumption is that this is happening because position of cursor is kinda unusual in this case, since otherwise it works just fine.

dgutov commented 4 months ago

Hi!

Here's a patch you can try:

diff --git a/inf-ruby.el b/inf-ruby.el
index 8682032..2e35c0b 100755
--- a/inf-ruby.el
+++ b/inf-ruby.el
@@ -591,7 +591,9 @@ the overlay."
           (let* ((beg (if (consp where)
                           (car where)
            (save-excursion
-                          (backward-sexp 1)
+                          (condition-case nil
+                              (backward-sexp 1)
+                            (scan-error nil))
                           (point))))
         (end (if (consp where)
                           (cdr where)

LMK if it helps with expand-region, I don't currently have it installed.

x3qt commented 4 months ago

Now it works as expected, thanks a lot! 🎉

dgutov commented 4 months ago

Thanks for testing, pushed.