Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Pry-Coolline causes display to flash #5

Closed
dwbutler opened this issue Mar 27, 2015 · 20 comments
Closed

Pry-Coolline causes display to flash #5

dwbutler opened this issue Mar 27, 2015 · 20 comments

Comments

@dwbutler
Copy link

Syntax highlighting as you type is a cool idea. However, on my machine the whole line "flashes" every time I type a new character. What I mean is that all of the text momentarily disappears, and then reappears again, every time my finger hits a key. It's pretty maddening.

I have no idea if it's just me - I couldn't find any relevant tickets in the Pry-Coolline issue tracker. I have no idea how to fix it myself.

In lieu of a fix, it would be nice if Pry-Coolline could simply be turned off via configuration. I checked the original Jazz Hands, and back then it was possible to disable Pry-Coolline. It looks like this was removed in Jazz Fingers. I can submit a pull request to add this functionality back in.

@plribeiro3000
Copy link
Owner

Sure @dwbutler . Thank you for the feedback.
I would love a PR. =)

I've made a fork to update some dependencies but i'm fearful i don't have enough knowledge and time to fix those issues.

@dwbutler
Copy link
Author

I appreciate that you take the time to maintain this!

I have no idea how to fix Pry-Coolline either. =) It appears to be replacing the entire line instead of just replacing the characters that changed color.

Hopefully I'll find some time to submit a PR soon.

@plribeiro3000
Copy link
Owner

@dwbutler Awesome.
I was thinking about the issue and perhaps you could try to test it on a clean enviroment. Perhaps something else you have in your operational system is the responsible. Are you using bash, zsh?
Linux, Windows or Mac?

@plribeiro3000
Copy link
Owner

@dwbutler Did you have the chance to take a deeper look at this issue?

@dwbutler
Copy link
Author

dwbutler commented Apr 3, 2015

Sorry, I have not.

I am using ohmyzsh on a Mac. Maybe I'll launch a vagrant box to test this out on a clean environment. Or try it in bash.

@skull-squadron
Copy link

Append this to your .pryrc

# Hack to disable coolline
t = ENV['TERM']
ENV['TERM'] = 'dumb'
begin
  require 'pry-coolline'
rescue LoadError
end
ENV['TERM'] = t

@dwbutler
Copy link
Author

dwbutler commented Jun 2, 2015

@plribeiro3000 Thanks for your work on making coolline configurable!

I just tried it out, and unfortunately it didn't work for me. I'm on a Rails 4.1 app using Bundler. Somehow, (and I can't figure out how), pry-coolline gets loaded up before Jazz Fingers even gets initialized. I tried adding gem 'jazz_fingers', require: false to my gem file, but somehow Bundler (or Rails?) is still autoloading pry-coolline. So pry-coolline ends up overriding Pry.input before Jazz Fingers even gets there.

I ended up adding the following to an initializer to fix this:

Pry.input = Readline

Perhaps Jazz Fingers could do something similar?

@plribeiro3000
Copy link
Owner

Have you create an initializer to require jazz_fingers/setup after you set Pry.coolline to false?

If is is the case then i have to remove pry-cooline dependency and let it up to the developer to add it manually.

@dwbutler
Copy link
Author

dwbutler commented Jun 3, 2015

@plribeiro3000 Yes, I used the example from the readme.

Removing pry-coolline as a dependency might be overkill. I think overriding Pry.input if coolline is turned off could work. Not loading up coolline if you're not planning to use it sounds nice too.

Now I'm wondering how the original Jazz Hands got this to work...

@plribeiro3000
Copy link
Owner

Hmm. Interesting. I will try your approach. It seems good. =)

@plribeiro3000
Copy link
Owner

@dwbutler Could you try the latest master?

I believe that issue is related to bundler automatically loading pry-coolline since it is a dependency in jazz_fingers.gemspec. I just moved it to the Gemfile so i can control when something will get loaded if it will get loaded at all.

@aried3r
Copy link
Contributor

aried3r commented Jun 17, 2015

I tested this using the master branch, from what I can tell, this means I have to manually add all the pry-dependencies myself to my Gemfile? Because now, this gem doesn't depend on anything anymore.

+GIT
+  remote: git://github.com/plribeiro3000/jazz_fingers.git
+  revision: f5ed02c0799c9994b2128a23751868c146df2c37
+  specs:
+    jazz_fingers (2.0.0)
+
-    jazz_fingers (2.0.0)
-      awesome_print (~> 1.6)
-      hirb (~> 0.7)
-      pry (~> 0.10)
-      pry-byebug (~> 3.1)
-      pry-coolline (~> 0.2)
-      pry-doc (~> 0.6)
-      pry-git (~> 0.2)
-      pry-remote (>= 0.1.7)

@plribeiro3000
Copy link
Owner

Nope, it does depend on other projects, just like before.

The only change is that now the dependencies are in the Gemfile to create a better control over the dependencies.

For more details take a look at add3972

@aried3r
Copy link
Contributor

aried3r commented Jun 17, 2015

I saw that, but once I added jazz_fingers using github: plriberio3000/jazz_fingers, all other dependencies vanished from my Gemfile.lock, rendering this gem useless. I might have done something wrong, could you please verify?

Btw, I'm no gem developer, so I don't have much insight, but according to the ruby gems website:

Setting dependencies in your gemspec is easy. Just use add_runtime_dependency and add_development_dependency:

And, from an article from 2010 by Yehuda Katz (so this might not be accurate anymore):

When developing a gem, use the gemspec method in your Gemfile to avoid duplication. In general, a gem's Gemfile should contain the Rubygems source and a single gemspec line.

@aried3r
Copy link
Contributor

aried3r commented Jun 17, 2015

This is in a fresh rails app, adding only these two lines to the Gemfile and running bundle install

group :development, :test do
  gem 'jazz_fingers', github: 'plribeiro3000/jazz_fingers'
  gem 'pry-rails'
end
diff --git a/Gemfile b/Gemfile
index f7a0b56..02a660e 100644
--- a/Gemfile
+++ b/Gemfile
@@ -41,5 +41,8 @@ group :development, :test do

   # Spring speeds up development by keeping your application running in the background. Read more: https://github.com/rails/spring
   gem 'spring'
-end

+  gem 'jazz_fingers', github: 'plribeiro3000/jazz_fingers'
+  gem 'pry-rails'
+end
diff --git a/Gemfile.lock b/Gemfile.lock
index 42d22ef..8d04f59 100644
--- a/Gemfile.lock
+++ b/Gemfile.lock
@@ -1,3 +1,9 @@
+GIT
+  remote: git://github.com/plribeiro3000/jazz_fingers.git
+  revision: f5ed02c0799c9994b2128a23751868c146df2c37
+  specs:
+    jazz_fingers (2.0.0)
+
 GEM
   remote: https://rubygems.org/
   specs:
@@ -42,6 +48,7 @@ GEM
     builder (3.2.2)
     byebug (5.0.0)
       columnize (= 0.9.0)
+    coderay (1.1.0)
     coffee-rails (4.1.0)
       coffee-script (>= 2.2.0)
       railties (>= 4.0.0, < 5.0)
@@ -68,12 +75,19 @@ GEM
       nokogiri (>= 1.5.9)
     mail (2.6.3)
       mime-types (>= 1.16, < 3)
+    method_source (0.8.2)
     mime-types (2.6.1)
     mini_portile (0.6.2)
     minitest (5.7.0)
     multi_json (1.11.1)
     nokogiri (1.6.6.2)
       mini_portile (~> 0.6.0)
+    pry (0.10.1)
+      coderay (~> 1.1.0)
+      method_source (~> 0.8.1)
+      slop (~> 3.4)
+    pry-rails (0.3.4)
+      pry (>= 0.9.10)
     rack (1.6.2)
     rack-test (0.6.3)
       rack (>= 1.0)
@@ -113,6 +127,7 @@ GEM
     sdoc (0.4.1)
       json (~> 1.7, >= 1.7.7)
       rdoc (~> 4.0)
+    slop (3.6.0)
     spring (1.3.6)
     sprockets (3.2.0)
       rack (~> 1.0)
@@ -143,8 +158,10 @@ PLATFORMS
 DEPENDENCIES
   byebug
   coffee-rails (~> 4.1.0)
+  jazz_fingers!
   jbuilder (~> 2.0)
   jquery-rails
+  pry-rails
   rails (= 4.2.2)
   sass-rails (~> 5.0)
   sdoc (~> 0.4.0)

which of course results in errors like this one:

$ rails console
/usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/jazz_fingers-f5ed02c0799c/lib/jazz_fingers.rb:1:in `require': cannot load such file -- hirb (LoadError)
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/bundler/gems/jazz_fingers-f5ed02c0799c/lib/jazz_fingers.rb:1:in `<top (required)>'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler/runtime.rb:76:in `require'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler/runtime.rb:76:in `block (2 levels) in require'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler/runtime.rb:72:in `each'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler/runtime.rb:72:in `block in require'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler/runtime.rb:61:in `each'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler/runtime.rb:61:in `require'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/bundler-1.10.4/lib/bundler.rb:134:in `require'
    from /private/tmp/jazz_fingers_test/config/application.rb:7:in `<top (required)>'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/application.rb:82:in `require'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/application.rb:82:in `preload'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/application.rb:143:in `serve'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/application.rb:131:in `block in run'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/application.rb:125:in `loop'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/application.rb:125:in `run'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/gems/2.2.0/gems/spring-1.3.6/lib/spring/application/boot.rb:18:in `<top (required)>'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from /usr/local/opt/rbenv/versions/2.2.2/lib/ruby/site_ruby/2.2.0/rubygems/core_ext/kernel_require.rb:54:in `require'
    from -e:1:in `<main>'

@plribeiro3000
Copy link
Owner

Hmmm. interesting. That was not what i was expecting since the Gemfile does reference the gemspec one. See here. Maybe is just the order (gemspec should be before). I will do some testing later. =)

@plribeiro3000 plribeiro3000 reopened this Jun 27, 2015
@plribeiro3000
Copy link
Owner

@dwbutler @steakknife @aried3r Could you guys try the version 2.0.1.rc1?

I just confirmed on a new fresh install of rails that it is working as intended.

@aried3r
Copy link
Contributor

aried3r commented Jun 29, 2015

Seems to work for me, thanks!

@plribeiro3000
Copy link
Owner

Awesome. Thanks for the feedback!

@Lujaw
Copy link

Lujaw commented Jan 20, 2016

@aried3r Worked for me too. Thanks

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

5 participants