mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-08 08:02:06 -07:00
Remove special nilItem
This commit is contained in:
25
src/core.go
25
src/core.go
@@ -85,29 +85,30 @@ func Run(opts *Options, revision string) {
|
||||
var chunkList *ChunkList
|
||||
header := make([]string, 0, opts.HeaderLines)
|
||||
if len(opts.WithNth) == 0 {
|
||||
chunkList = NewChunkList(func(data []byte, index int) Item {
|
||||
chunkList = NewChunkList(func(item *Item, data []byte, index int) bool {
|
||||
if len(header) < opts.HeaderLines {
|
||||
header = append(header, string(data))
|
||||
eventBox.Set(EvtHeader, header)
|
||||
return nilItem
|
||||
return false
|
||||
}
|
||||
chars, colors := ansiProcessor(data)
|
||||
chars.Index = int32(index)
|
||||
return Item{text: chars, colors: colors}
|
||||
item.text, item.colors = ansiProcessor(data)
|
||||
item.text.Index = int32(index)
|
||||
return true
|
||||
})
|
||||
} else {
|
||||
chunkList = NewChunkList(func(data []byte, index int) Item {
|
||||
chunkList = NewChunkList(func(item *Item, data []byte, index int) bool {
|
||||
tokens := Tokenize(string(data), opts.Delimiter)
|
||||
trans := Transform(tokens, opts.WithNth)
|
||||
transformed := joinTokens(trans)
|
||||
if len(header) < opts.HeaderLines {
|
||||
header = append(header, transformed)
|
||||
eventBox.Set(EvtHeader, header)
|
||||
return nilItem
|
||||
return false
|
||||
}
|
||||
trimmed, colors := ansiProcessor([]byte(transformed))
|
||||
trimmed.Index = int32(index)
|
||||
return Item{text: trimmed, colors: colors, origText: &data}
|
||||
item.text, item.colors = ansiProcessor([]byte(transformed))
|
||||
item.text.Index = int32(index)
|
||||
item.origText = &data
|
||||
return true
|
||||
})
|
||||
}
|
||||
|
||||
@@ -151,8 +152,8 @@ func Run(opts *Options, revision string) {
|
||||
slab := util.MakeSlab(slab16Size, slab32Size)
|
||||
reader := Reader{
|
||||
func(runes []byte) bool {
|
||||
item := chunkList.trans(runes, 0)
|
||||
if !item.Nil() {
|
||||
item := Item{}
|
||||
if chunkList.trans(&item, runes, 0) {
|
||||
if result, _, _ := pattern.MatchItem(&item, false, slab); result != nil {
|
||||
opts.Printer(item.text.ToString())
|
||||
found = true
|
||||
|
Reference in New Issue
Block a user