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

Editing history corrupts history rather than appending to history #2302

Open
zenspider opened this issue Mar 5, 2024 · 3 comments
Open

Editing history corrupts history rather than appending to history #2302

zenspider opened this issue Mar 5, 2024 · 3 comments

Comments

@zenspider
Copy link

zenspider commented Mar 5, 2024

9985 $ pry --no-history -f
[1] pry(main)> 1 + 2
=> 3
[2] pry(main)> hist
1: 1 + 2
[3] pry(main)> 1 + 3      # NOTE: used `up up` and changed 2 to 3
=> 4
[4] pry(main)> hist
1: 1 + 3
2: hist
3: 1 + 3

Expected:

1: 1 + 2
2: hist
3: 1 + 3

Without the hist in between, it is a tad more confusing but illustrates my point even more:

9986 $ pry --no-history -f
[1] pry(main)> 1 + 2
=> 3
[2] pry(main)> 1 + 3      # up + edit
=> 4
[3] pry(main)> hist
1: 1 + 3

Expected:

1: 1 + 2
2: 1 + 3

example from bash:

9984 $ echo hello
hello
9985 $ echo goodbye       # up + edit
goodbye
9986 $ history | tail -3
 9984  echo hello
 9985  echo goodbye
 9986  history | tail -3
@sinexton
Copy link

I confirm, the history gets messed up. This is a critical bug. Thanks.

@Slokilla
Copy link

Is there some work in progress on it ? Or do you need contributions ?

@andrehjr
Copy link
Member

andrehjr commented Mar 23, 2024

Hi, thanks for the issue! I investigated and narrowed down the issue to Reline (when used in pry as Input instead of Readline).

This will be fixed by #2298 it's only happening right when pry is using Reline (default from Ruby 3.3+). I want to polish the Reline integration a bit more before merging. Any help testing it will be much appreciated!

A quick workaround is to bring back Readline by installing gem install readline-ext.

~ » pry
[1] pry(main)> Readline
=> Reline
[2] pry(main)> 1 + 1
=> 2
[3] pry(main)> 1 + 2 # up + edit
=> 3
[4] pry(main)> 1 + 2
=> 3
[5] pry(main)> hist
1: Readline
2: 1 + 2
3: 1 + 2
[6] pry(main)> exit

~ » gem install readline-ext
~ » pry
[1] pry(main)> Readline
=> Readline
[2] pry(main)> 1 + 1
=> 2
[3] pry(main)> 1 + 5 # up + edit
=> 6
[4] pry(main)> 1 + 2 # up + edit
=> 3
[5] pry(main)> 1 + 5 # up + edit
=> 6
[6] pry(main)> hist
1: Readline
2: 1 + 1
3: 1 + 5
4: 1 + 2
5: 1 + 5
[7] pry(main)>

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

4 participants