Skip to content

Commit

Permalink
fix fwd/bck search
Browse files Browse the repository at this point in the history
  • Loading branch information
chzyer committed Sep 23, 2015
1 parent a7f498f commit 41404cd
Showing 1 changed file with 7 additions and 6 deletions.
13 changes: 7 additions & 6 deletions history.go
Original file line number Diff line number Diff line change
Expand Up @@ -65,10 +65,9 @@ func (o *opHistory) FindHistoryBck(isNewSearch bool, rs []rune, start int) (int,
start += len(rs)
}
if elem == o.current {
if len(item) < start {
continue
if len(item) >= start {
item = item[:start]
}
item = item[:start]
}
idx := RunesIndexBck(item, rs)
if idx < 0 {
Expand All @@ -84,12 +83,14 @@ func (o *opHistory) FindHistoryFwd(isNewSearch bool, rs []rune, start int) (int,
item := o.showItem(elem.Value)
if isNewSearch {
start -= len(rs)
if start < 0 {
start = 0
}
}
if elem == o.current {
if len(item)-1 < start {
continue
if len(item)-1 >= start {
item = item[start:]
}
item = item[start:]
}
idx := RunesIndex(item, rs)
if idx < 0 {
Expand Down

0 comments on commit 41404cd

Please sign in to comment.