Comparing version 0.0.1 to 0.0.2
{ | ||
"name": "node-fzf", | ||
"version": "0.0.1", | ||
"version": "0.0.2", | ||
"description": "fzf ( junegunn/fzf ) inspired cli utility for node", | ||
@@ -5,0 +5,0 @@ "main": "src/index.js", |
@@ -35,2 +35,3 @@ const keypress = require( 'keypress' ) | ||
let buffer = '' | ||
let _printedMatches = 0 | ||
@@ -239,3 +240,3 @@ let list = _list || [] | ||
MIN_HEIGHT, | ||
2 + matches.length | ||
2 + _printedMatches | ||
) | ||
@@ -293,4 +294,14 @@ | ||
_printedMatches = 0 | ||
const maxPrintLength = Math.min( matches.length, MIN_HEIGHT ) | ||
const startIndex = Math.max( 0, offset - maxPrintLength + Math.ceil( MIN_HEIGHT * 0.25 ) ) | ||
const matchLimit = Math.min( maxPrintLength + startIndex, matches.length ) | ||
// print matches | ||
for ( let i = 0; i < matches.length ; i++ ) { | ||
for ( let i = startIndex; i < matchLimit; i++ ) { | ||
_printedMatches++ | ||
const match = matches[ i ] | ||
@@ -317,3 +328,3 @@ | ||
stdout.write( clc.move.up( 2 + matches.length ) ) | ||
stdout.write( clc.move.up( 2 + _printedMatches ) ) | ||
stdout.write( clc.move.right( 1 + buffer.length + 1 ) ) | ||
@@ -320,0 +331,0 @@ } |
9150
301