From ccca34f9f70a90b31ddc4a1daeb0727e955662db Mon Sep 17 00:00:00 2001 From: Junegunn Choi Date: Fri, 27 Jun 2014 12:35:30 +0900 Subject: [PATCH] Minor refactoring --- fzf | 16 +++++++--------- 1 file changed, 7 insertions(+), 9 deletions(-) diff --git a/fzf b/fzf index 015c6f8..465858f 100644 --- a/fzf +++ b/fzf @@ -703,12 +703,12 @@ class FZF def update_list wipe render do - offset, ycur, items = sync { + pos, items = sync { changed, @yoff, @ycur = constrain(@yoff, @ycur, @matches.length, max_items) wipe ||= changed - [@yoff, @ycur, @matches[@yoff, max_items]] + [@ycur - @yoff, @matches[@yoff, max_items]] } # Wipe @@ -720,20 +720,18 @@ class FZF end @plcount = items.length - maxc = C.cols - 3 - cline = ycur - offset - cleanse = Set[cline] + dirty = Set[pos] set(:@dirty) do |vs| - cleanse.merge vs + dirty.merge vs Set.new end items.each_with_index do |item, idx| - next unless wipe || cleanse.include?(idx) + next unless wipe || dirty.include?(idx) row = cursor_y(idx + 2) - chosen = idx == cline + chosen = idx == pos selected = @selects.include?([*item][0]) line, offsets = item - tokens = format line, maxc, offsets + tokens = format line, C.cols - 3, offsets print_item row, tokens, chosen, selected end print_info