forked from mirror/readline
fix fwd/bck search
This commit is contained in:
parent
a7f498f047
commit
41404cd3f9
13
history.go
13
history.go
|
@ -65,10 +65,9 @@ func (o *opHistory) FindHistoryBck(isNewSearch bool, rs []rune, start int) (int,
|
||||||
start += len(rs)
|
start += len(rs)
|
||||||
}
|
}
|
||||||
if elem == o.current {
|
if elem == o.current {
|
||||||
if len(item) < start {
|
if len(item) >= start {
|
||||||
continue
|
item = item[:start]
|
||||||
}
|
}
|
||||||
item = item[:start]
|
|
||||||
}
|
}
|
||||||
idx := RunesIndexBck(item, rs)
|
idx := RunesIndexBck(item, rs)
|
||||||
if idx < 0 {
|
if idx < 0 {
|
||||||
|
@ -84,12 +83,14 @@ func (o *opHistory) FindHistoryFwd(isNewSearch bool, rs []rune, start int) (int,
|
||||||
item := o.showItem(elem.Value)
|
item := o.showItem(elem.Value)
|
||||||
if isNewSearch {
|
if isNewSearch {
|
||||||
start -= len(rs)
|
start -= len(rs)
|
||||||
|
if start < 0 {
|
||||||
|
start = 0
|
||||||
|
}
|
||||||
}
|
}
|
||||||
if elem == o.current {
|
if elem == o.current {
|
||||||
if len(item)-1 < start {
|
if len(item)-1 >= start {
|
||||||
continue
|
item = item[start:]
|
||||||
}
|
}
|
||||||
item = item[start:]
|
|
||||||
}
|
}
|
||||||
idx := RunesIndex(item, rs)
|
idx := RunesIndex(item, rs)
|
||||||
if idx < 0 {
|
if idx < 0 {
|
||||||
|
|
Loading…
Reference in New Issue