-
Notifications
You must be signed in to change notification settings - Fork 8.3k
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
fix: only add to history of different #8197
base: mxyng/gods-v2
Are you sure you want to change the base?
Conversation
if the last item in history is the same as the one being added, skip it. this reduces the number of history entries. the behaviour is similar to how most shells maintain history
2951ebf
to
77e7e12
Compare
if i.History.Pos > 0 { | ||
if i.History.Pos == i.History.Size() { | ||
currentLineBuf = []rune(buf.String()) | ||
} | ||
buf.Replace([]rune(i.History.Prev())) | ||
} |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This and the block below are unnecessary since History.Prev()
and History.Next()
should return the correct line content; the logic is duplicated between here and readline/history.go
and it seems more appropriate for it to live there. The only benefit of having this conditional is omitting the call to Replace()
which doesn't seem worth it for the added complexity
|
||
f, err := os.OpenFile(path, os.O_CREATE|os.O_RDONLY, 0o600) | ||
if err != nil { | ||
if errors.Is(err, os.ErrNotExist) { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
This shouldn't be possible with O_CREATE
8b0bf9e
to
7570003
Compare
7570003
to
a1d90e6
Compare
if the last item in history is the same as the one being added, skip it. this reduces the number of history entries. the behaviour is similar to how most shells maintain history