diff --git a/app/sheet/read-data.c b/app/sheet/read-data.c index d6ea8a72..9d67e8c4 100644 --- a/app/sheet/read-data.c +++ b/app/sheet/read-data.c @@ -93,6 +93,15 @@ static int read_data(struct zsvsheet_ui_buffer **uibufferp, // a new zsvsheet_ if (uibuff->index_ready) { opts.header_span = 0; opts.rows_to_ignore = 0; + + if (uibuff->data_filename) { + struct zsv_opts filter_opts = {0}; + filter_opts.stream = opts.stream; + filter_opts.max_columns = opts.max_columns; + filter_opts.max_row_size = opts.max_row_size; + filter_opts.max_rows = opts.max_rows; + opts = filter_opts; + } zst = zsv_index_seek_row(uibuff->index, &opts, start_row); zsv_delete(parser); diff --git a/app/test/Makefile b/app/test/Makefile index 94348d06..6ae37f72 100644 --- a/app/test/Makefile +++ b/app/test/Makefile @@ -191,6 +191,9 @@ test-echo-overwrite-csv: ${BUILD_DIR}/bin/zsv_echo${EXE} ${TEST_DATA_DIR}/loans_ worldcitiespop_mil.csv: curl -LOk 'https://burntsushi.net/stuff/worldcitiespop_mil.csv' +worldcitiespop_mil.tsv: worldcitiespop_mil.csv ${BUILD_DIR}/bin/zsv_2tsv + ${BUILD_DIR}/bin/zsv_2tsv $< > $@ + test-count test-count-pull: test-% : test-1-% test-2-% test-cli: ${CLI} @@ -584,7 +587,7 @@ test-sheet: test-%: ${BUILD_DIR}/bin/zsv_%${EXE} worldcitiespop_mil.csv test-she test-sheet-cleanup: @rm -f tmux-*.log -test-sheet-all: test-sheet-1 test-sheet-2 test-sheet-3 test-sheet-4 test-sheet-5 test-sheet-6 test-sheet-7 test-sheet-8 test-sheet-9 +test-sheet-all: test-sheet-1 test-sheet-2 test-sheet-3 test-sheet-4 test-sheet-5 test-sheet-6 test-sheet-7 test-sheet-8 test-sheet-9 test-sheet-10 @(for SESSION in $^; do ! tmux kill-session -t "$$SESSION" 2>/dev/null; done && ${TEST_PASS} || ${TEST_FAIL}) TMUX_TERM=xterm-256color @@ -684,3 +687,15 @@ test-sheet-9: ${BUILD_DIR}/bin/zsv_sheet${EXE} tmux capture-pane -t $@ -p ${REDIRECT1} ${TMP_DIR}/$@.out && \ tmux send-keys -t $@ "q" && \ ${CMP} ${TMP_DIR}/$@.out expected/$@.out && ${TEST_PASS} || (echo 'Incorrect output:' && cat ${TMP_DIR}/$@.out && ${TEST_FAIL})) + +test-sheet-10: ${BUILD_DIR}/bin/zsv_sheet${EXE} worldcitiespop_mil.tsv + @${TEST_INIT} + @echo 'set-option default-terminal "${TMUX_TERM}"' > ~/.tmux.conf + @(tmux new-session -x 80 -y 6 -d -s $@ "${PREFIX} $< -t worldcitiespop_mil.tsv" && \ + sleep 0.5 && \ + tmux send-keys -t $@ "f" "e" "Enter" && \ + sleep 1 && \ + tmux send-keys -t $@ "G" && \ + tmux capture-pane -t $@ -p ${REDIRECT1} ${TMP_DIR}/$@.out && \ + tmux send-keys -t $@ "q" && \ + ${CMP} ${TMP_DIR}/$@.out expected/$@.out && ${TEST_PASS} || (echo 'Incorrect output:' && cat ${TMP_DIR}/$@.out && ${TEST_FAIL})) diff --git a/app/test/expected/test-sheet-10.out b/app/test/expected/test-sheet-10.out new file mode 100644 index 00000000..405e9944 --- /dev/null +++ b/app/test/expected/test-sheet-10.out @@ -0,0 +1,6 @@ +Row # Country City AccentCit Region Populatio Latitude Longitude +493036 gb rutupiae RutupiƦ G5 51.283333 1.333333 +493037 lv briezucie Briezucie 03 56.95 27.583333 +493038 gw quenem Quenem 04 12.228333 -15.64444 +493039 gb ryde Ryde G2 24107 50.716667 -1.166667 +(493039 filtered rows) 493039