Minor refactoring
This commit is contained in:
parent
b5350b24ff
commit
ccca34f9f7
16
fzf
16
fzf
@ -703,12 +703,12 @@ class FZF
|
|||||||
|
|
||||||
def update_list wipe
|
def update_list wipe
|
||||||
render do
|
render do
|
||||||
offset, ycur, items = sync {
|
pos, items = sync {
|
||||||
changed, @yoff, @ycur =
|
changed, @yoff, @ycur =
|
||||||
constrain(@yoff, @ycur, @matches.length, max_items)
|
constrain(@yoff, @ycur, @matches.length, max_items)
|
||||||
wipe ||= changed
|
wipe ||= changed
|
||||||
|
|
||||||
[@yoff, @ycur, @matches[@yoff, max_items]]
|
[@ycur - @yoff, @matches[@yoff, max_items]]
|
||||||
}
|
}
|
||||||
|
|
||||||
# Wipe
|
# Wipe
|
||||||
@ -720,20 +720,18 @@ class FZF
|
|||||||
end
|
end
|
||||||
@plcount = items.length
|
@plcount = items.length
|
||||||
|
|
||||||
maxc = C.cols - 3
|
dirty = Set[pos]
|
||||||
cline = ycur - offset
|
|
||||||
cleanse = Set[cline]
|
|
||||||
set(:@dirty) do |vs|
|
set(:@dirty) do |vs|
|
||||||
cleanse.merge vs
|
dirty.merge vs
|
||||||
Set.new
|
Set.new
|
||||||
end
|
end
|
||||||
items.each_with_index do |item, idx|
|
items.each_with_index do |item, idx|
|
||||||
next unless wipe || cleanse.include?(idx)
|
next unless wipe || dirty.include?(idx)
|
||||||
row = cursor_y(idx + 2)
|
row = cursor_y(idx + 2)
|
||||||
chosen = idx == cline
|
chosen = idx == pos
|
||||||
selected = @selects.include?([*item][0])
|
selected = @selects.include?([*item][0])
|
||||||
line, offsets = item
|
line, offsets = item
|
||||||
tokens = format line, maxc, offsets
|
tokens = format line, C.cols - 3, offsets
|
||||||
print_item row, tokens, chosen, selected
|
print_item row, tokens, chosen, selected
|
||||||
end
|
end
|
||||||
print_info
|
print_info
|
||||||
|
Loading…
Reference in New Issue
Block a user