Closed Silex closed 7 years ago
@Silex I see where you're heading with this.
You know what looking at it now I think that instead of calling run-ruby
in projectile-rails-console
we should be calling inf-ruby-console-run
. Something like this:
(defun projectile-rails-console (arg)
"Start a rails console"
(interactive "P")
(projectile-rails-with-root
(let ((rails-console-command (projectile-rails-with-preloader
:spring (concat projectile-rails-spring-command " rails console")
:zeus "zeus console"
:vanilla (concat projectile-rails-vanilla-command " console"))))
(inf-ruby-console-run
(if (>= (or (car arg) 0) 4)
(read-string "rails console: " rails-console-command)
rails-console-command)
"rails")
(projectile-rails-mode +1))))
This code works for my project although I'm seeing error in the mini buffer: "run-ruby-or-pop-to-buffer: Found inf-ruby buffer, but it was created using a different NAME-COMMAND combination: rails, ‘bundle exec rails console’" Maybe it has something to do with the fact that I'm using Spring.
@asok: yeah it's weird. I need to setup an env where I can edebug this, because theorically ruby-run
should reuse the same buffer. It has project detection... so maybe we don't really need to fix anything else than adding some dummy Gemfile or whatever.
See https://github.com/nonsequitur/inf-ruby/commit/5aaa7e879ce4f900cac9ac4be8d67a127c232566
EDIT: ha, apparently you're right with inf-ruby-console-run
. I'll give it a try tomorrow.
@asok: I think we are good to go! Shall I merge?
I still get this error when I call the command for the second time. I think that's because when I call the command for the first time it runs it as bundle exec rails console
. Now because there some kind of bin stub it starts spring also. So if I run the command for the second time it calls inf-ruby-console-run
with bundle exec spring rails console
.
I think the best will be if you merge it like that. I'll take it over from there and I'll wrap the call to -console-run
in with-demoted-errors
.
Temporary PR to test that the test fixing works before pushing to master.