forked from mirror/readline
fix fwd/bck search
This commit is contained in:
parent
a7f498f047
commit
41404cd3f9
13
history.go
13
history.go
|
@ -65,11 +65,10 @@ 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 {
|
||||||
continue
|
continue
|
||||||
|
@ -84,13 +83,15 @@ 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 {
|
||||||
continue
|
continue
|
||||||
|
|
Loading…
Reference in New Issue