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's command history malfunctions when pry-coolline's active #28

Open
pabloh opened this issue Jul 24, 2014 · 3 comments
Open

Pry's command history malfunctions when pry-coolline's active #28

pabloh opened this issue Jul 24, 2014 · 3 comments

Comments

@pabloh
Copy link

pabloh commented Jul 24, 2014

Where using pry (0.10.0) with pry-coolline (0.2.4) and cooline (0.4.4), you need to push the up arrow button twice (instead of once) to get the last entered expression, like there was always an extra empty entry at the command history.

This is happening to me using ruby 2.1.2p95 (2014-05-08 revision 45877) [x86_64-linux].

@pabloh pabloh changed the title Pry's command history malfunctions when coolline active Pry's command history malfunctions when pry-coolline active Jul 24, 2014
@pabloh pabloh changed the title Pry's command history malfunctions when pry-coolline active Pry's command history malfunctions when pry-coolline's active Jul 24, 2014
@clessg
Copy link

clessg commented Jan 28, 2015

Same problem here.

@anothermh
Copy link

This appears to be a problem because both the coolline gem and the pry gem are writing to the same .pry_history file:

Since both pry and coolline are writing to the history file, you appear to have to up-arrow twice to get to the last command, but it is actually first reading the entry from pry, and second reading the entry from coolline. You can confirm this with a simple monkey-patch to https://github.com/Mon-Ouie/coolline/blob/0ced8fc48dd3e62bc1b0cd8e819197424aac3b32/lib/coolline/history.rb#L64: @io.puts "#{self[-1]}-coolline" will force coolline to append -coolline to the entry that it saves to the history.

Either way, the fix is to monkey-patch either coolline (so it doesn't try to save the history file at all) or pry-coolline (so it passes in a null file for the history, e.g., cool.history_file = File.open(File::NULL, "w") at https://github.com/pry/pry-coolline/blob/master/lib/pry-coolline/wrapper.rb#L35).

I can't see why either pry-coolline or coolline need access to the pry history to be able to serve their intended purposes here, but there may be context that I am missing that @banister can explain.

@anothermh
Copy link

I looked into this more last night and was wrong about it. Ultimately, since both coolline and pry are going to try to write to the history file, I resolved it by editing my .pryrc file to include Pry.config.history.should_save = false if defined?(PryCoolline) so pry doesn't attempt to write to the history if pry-coolline is enabled. Now only coolline writes to the history file, and double-entries have been stopped.

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

3 participants