mirror of
https://github.com/junegunn/fzf.git
synced 2025-08-25 01:13:50 -07:00
Add --header-lines option
This commit is contained in:
@@ -26,8 +26,13 @@ func NewChunkList(trans ItemBuilder) *ChunkList {
|
||||
trans: trans}
|
||||
}
|
||||
|
||||
func (c *Chunk) push(trans ItemBuilder, data *string, index int) {
|
||||
*c = append(*c, trans(data, index))
|
||||
func (c *Chunk) push(trans ItemBuilder, data *string, index int) bool {
|
||||
item := trans(data, index)
|
||||
if item != nil {
|
||||
*c = append(*c, item)
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// IsFull returns true if the Chunk is full
|
||||
@@ -48,7 +53,7 @@ func CountItems(cs []*Chunk) int {
|
||||
}
|
||||
|
||||
// Push adds the item to the list
|
||||
func (cl *ChunkList) Push(data string) {
|
||||
func (cl *ChunkList) Push(data string) bool {
|
||||
cl.mutex.Lock()
|
||||
defer cl.mutex.Unlock()
|
||||
|
||||
@@ -57,8 +62,11 @@ func (cl *ChunkList) Push(data string) {
|
||||
cl.chunks = append(cl.chunks, &newChunk)
|
||||
}
|
||||
|
||||
cl.lastChunk().push(cl.trans, &data, cl.count)
|
||||
cl.count++
|
||||
if cl.lastChunk().push(cl.trans, &data, cl.count) {
|
||||
cl.count++
|
||||
return true
|
||||
}
|
||||
return false
|
||||
}
|
||||
|
||||
// Snapshot returns immutable snapshot of the ChunkList
|
||||
|
Reference in New Issue
Block a user