From f03894c25b50d032bb9a0a7f9cc0b7c94c7b3852 Mon Sep 17 00:00:00 2001 From: LoricAndre <57358788+LoricAndre@users.noreply.github.com> Date: Mon, 19 Jan 2026 21:17:42 +0100 Subject: [PATCH] test: fix wrap test (#896) * test: fix wrap test * chore: generate completions & manpage * fix: fix test --------- Co-authored-by: Skim bot --- man/man1/sk.1 | 5 ++++- shell/completion.bash | 2 +- shell/completion.fish | 1 + shell/completion.nu | 1 + shell/completion.zsh | 1 + tests/case.rs | 10 ++++++++++ tests/options.rs | 4 ++-- 7 files changed, 20 insertions(+), 4 deletions(-) diff --git a/man/man1/sk.1 b/man/man1/sk.1 index 0b85febb..1f0ae479 100644 --- a/man/man1/sk.1 +++ b/man/man1/sk.1 @@ -4,7 +4,7 @@ .SH NAME sk \- Fuzzy Finder in rust! .SH SYNOPSIS -\fBsk\fR [\fB\-\-tac\fR] [\fB\-\-min\-query\-length\fR] [\fB\-\-no\-sort\fR] [\fB\-t\fR|\fB\-\-tiebreak\fR] [\fB\-n\fR|\fB\-\-nth\fR] [\fB\-\-with\-nth\fR] [\fB\-d\fR|\fB\-\-delimiter\fR] [\fB\-e\fR|\fB\-\-exact\fR] [\fB\-\-regex\fR] [\fB\-\-algo\fR] [\fB\-\-case\fR] [\fB\-b\fR|\fB\-\-bind\fR] [\fB\-m\fR|\fB\-\-multi\fR] [\fB\-\-no\-multi\fR] [\fB\-\-no\-mouse\fR] [\fB\-c\fR|\fB\-\-cmd\fR] [\fB\-i\fR|\fB\-\-interactive\fR] [\fB\-I \fR] [\fB\-\-color\fR] [\fB\-\-no\-hscroll\fR] [\fB\-\-keep\-right\fR] [\fB\-\-skip\-to\-pattern\fR] [\fB\-\-no\-clear\-if\-empty\fR] [\fB\-\-no\-clear\-start\fR] [\fB\-\-no\-clear\fR] [\fB\-\-show\-cmd\-error\fR] [\fB\-\-cycle\fR] [\fB\-\-disabled\fR] [\fB\-\-layout\fR] [\fB\-\-reverse\fR] [\fB\-\-height\fR] [\fB\-\-no\-height\fR] [\fB\-\-min\-height\fR] [\fB\-\-margin\fR] [\fB\-p\fR|\fB\-\-prompt\fR] [\fB\-\-cmd\-prompt\fR] [\fB\-\-selector\fR] [\fB\-\-multi\-selector\fR] [\fB\-\-ansi\fR] [\fB\-\-tabstop\fR] [\fB\-\-info\fR] [\fB\-\-no\-info\fR] [\fB\-\-inline\-info\fR] [\fB\-\-header\fR] [\fB\-\-header\-lines\fR] [\fB\-\-border\fR] [\fB\-\-history\fR] [\fB\-\-history\-size\fR] [\fB\-\-cmd\-history\fR] [\fB\-\-cmd\-history\-size\fR] [\fB\-\-preview\fR] [\fB\-\-preview\-window\fR] [\fB\-q\fR|\fB\-\-query\fR] [\fB\-\-cmd\-query\fR] [\fB\-\-read0\fR] [\fB\-\-print0\fR] [\fB\-\-print\-query\fR] [\fB\-\-print\-cmd\fR] [\fB\-\-print\-score\fR] [\fB\-\-print\-header\fR] [\fB\-1\fR|\fB\-\-select\-1\fR] [\fB\-0\fR|\fB\-\-exit\-0\fR] [\fB\-\-sync\fR] [\fB\-\-pre\-select\-n\fR] [\fB\-\-pre\-select\-pat\fR] [\fB\-\-pre\-select\-items\fR] [\fB\-\-pre\-select\-file\fR] [\fB\-f\fR|\fB\-\-filter\fR] [\fB\-\-shell\fR] [\fB\-\-shell\-bindings\fR] [\fB\-\-man\fR] [\fB\-\-listen\fR] [\fB\-\-tmux\fR] [\fB\-\-log\-file\fR] [\fB\-\-expect\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] +\fBsk\fR [\fB\-\-tac\fR] [\fB\-\-min\-query\-length\fR] [\fB\-\-no\-sort\fR] [\fB\-t\fR|\fB\-\-tiebreak\fR] [\fB\-n\fR|\fB\-\-nth\fR] [\fB\-\-with\-nth\fR] [\fB\-d\fR|\fB\-\-delimiter\fR] [\fB\-e\fR|\fB\-\-exact\fR] [\fB\-\-regex\fR] [\fB\-\-algo\fR] [\fB\-\-case\fR] [\fB\-b\fR|\fB\-\-bind\fR] [\fB\-m\fR|\fB\-\-multi\fR] [\fB\-\-no\-multi\fR] [\fB\-\-no\-mouse\fR] [\fB\-c\fR|\fB\-\-cmd\fR] [\fB\-i\fR|\fB\-\-interactive\fR] [\fB\-I \fR] [\fB\-\-color\fR] [\fB\-\-no\-hscroll\fR] [\fB\-\-keep\-right\fR] [\fB\-\-skip\-to\-pattern\fR] [\fB\-\-no\-clear\-if\-empty\fR] [\fB\-\-no\-clear\-start\fR] [\fB\-\-no\-clear\fR] [\fB\-\-show\-cmd\-error\fR] [\fB\-\-cycle\fR] [\fB\-\-disabled\fR] [\fB\-\-layout\fR] [\fB\-\-reverse\fR] [\fB\-\-height\fR] [\fB\-\-no\-height\fR] [\fB\-\-min\-height\fR] [\fB\-\-margin\fR] [\fB\-p\fR|\fB\-\-prompt\fR] [\fB\-\-cmd\-prompt\fR] [\fB\-\-selector\fR] [\fB\-\-multi\-selector\fR] [\fB\-\-ansi\fR] [\fB\-\-tabstop\fR] [\fB\-\-info\fR] [\fB\-\-no\-info\fR] [\fB\-\-inline\-info\fR] [\fB\-\-header\fR] [\fB\-\-header\-lines\fR] [\fB\-\-border\fR] [\fB\-\-wrap\fR] [\fB\-\-history\fR] [\fB\-\-history\-size\fR] [\fB\-\-cmd\-history\fR] [\fB\-\-cmd\-history\-size\fR] [\fB\-\-preview\fR] [\fB\-\-preview\-window\fR] [\fB\-q\fR|\fB\-\-query\fR] [\fB\-\-cmd\-query\fR] [\fB\-\-read0\fR] [\fB\-\-print0\fR] [\fB\-\-print\-query\fR] [\fB\-\-print\-cmd\fR] [\fB\-\-print\-score\fR] [\fB\-\-print\-header\fR] [\fB\-1\fR|\fB\-\-select\-1\fR] [\fB\-0\fR|\fB\-\-exit\-0\fR] [\fB\-\-sync\fR] [\fB\-\-pre\-select\-n\fR] [\fB\-\-pre\-select\-pat\fR] [\fB\-\-pre\-select\-items\fR] [\fB\-\-pre\-select\-file\fR] [\fB\-f\fR|\fB\-\-filter\fR] [\fB\-\-shell\fR] [\fB\-\-shell\-bindings\fR] [\fB\-\-man\fR] [\fB\-\-listen\fR] [\fB\-\-tmux\fR] [\fB\-\-log\-file\fR] [\fB\-\-expect\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR] .SH DESCRIPTION sk \- fuzzy finder in Rust .PP @@ -670,6 +670,9 @@ The first N lines of the input are treated as the sticky header. When \-\-with\ \fB\-\-border\fR Draw borders around the UI components .TP +\fB\-\-wrap\fR +Wrap items in the item list +.TP \fB\-\-tmux\fR [\fI...\fR] Run in a tmux popup diff --git a/shell/completion.bash b/shell/completion.bash index 984e88c6..82b48335 100644 --- a/shell/completion.bash +++ b/shell/completion.bash @@ -23,7 +23,7 @@ _sk() { case "${cmd}" in sk) - opts="-t -n -d -e -b -m -c -i -I -p -q -1 -0 -f -x -h -V --tac --min-query-length --no-sort --tiebreak --nth --with-nth --delimiter --exact --regex --algo --case --bind --multi --no-multi --no-mouse --cmd --interactive --color --no-hscroll --keep-right --skip-to-pattern --no-clear-if-empty --no-clear-start --no-clear --show-cmd-error --cycle --disabled --layout --reverse --height --no-height --min-height --margin --prompt --cmd-prompt --selector --multi-selector --ansi --tabstop --info --no-info --inline-info --header --header-lines --border --history --history-size --cmd-history --cmd-history-size --preview --preview-window --query --cmd-query --read0 --print0 --print-query --print-cmd --print-score --print-header --select-1 --exit-0 --sync --pre-select-n --pre-select-pat --pre-select-items --pre-select-file --filter --shell --shell-bindings --man --listen --tmux --log-file --extended --literal --hscroll-off --filepath-word --jump-labels --no-bold --phony --expect --help --version" + opts="-t -n -d -e -b -m -c -i -I -p -q -1 -0 -f -x -h -V --tac --min-query-length --no-sort --tiebreak --nth --with-nth --delimiter --exact --regex --algo --case --bind --multi --no-multi --no-mouse --cmd --interactive --color --no-hscroll --keep-right --skip-to-pattern --no-clear-if-empty --no-clear-start --no-clear --show-cmd-error --cycle --disabled --layout --reverse --height --no-height --min-height --margin --prompt --cmd-prompt --selector --multi-selector --ansi --tabstop --info --no-info --inline-info --header --header-lines --border --wrap --history --history-size --cmd-history --cmd-history-size --preview --preview-window --query --cmd-query --read0 --print0 --print-query --print-cmd --print-score --print-header --select-1 --exit-0 --sync --pre-select-n --pre-select-pat --pre-select-items --pre-select-file --filter --shell --shell-bindings --man --listen --tmux --log-file --extended --literal --hscroll-off --filepath-word --jump-labels --no-bold --phony --expect --help --version" if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) return 0 diff --git a/shell/completion.fish b/shell/completion.fish index f7a78ef0..13674f87 100644 --- a/shell/completion.fish +++ b/shell/completion.fish @@ -86,6 +86,7 @@ complete -c sk -l ansi -d 'Parse ANSI color codes in input strings' complete -c sk -l no-info -d 'Alias for --info=hidden' complete -c sk -l inline-info -d 'Alias for --info=inline' complete -c sk -l border -d 'Draw borders around the UI components' +complete -c sk -l wrap -d 'Wrap items in the item list' complete -c sk -l read0 -d 'Read input delimited by ASCII NUL(\\0) characters' complete -c sk -l print0 -d 'Print output delimited by ASCII NUL(\\0) characters' complete -c sk -l print-query -d 'Print the query as the first line' diff --git a/shell/completion.nu b/shell/completion.nu index 514c8824..115243d6 100644 --- a/shell/completion.nu +++ b/shell/completion.nu @@ -72,6 +72,7 @@ module completions { --header: string # Set header, displayed next to the info --header-lines: string # Number of lines of the input treated as header --border # Draw borders around the UI components + --wrap # Wrap items in the item list --history: string # History file --history-size: string # Maximum number of query history entries to keep --cmd-history: string # Command history file diff --git a/shell/completion.zsh b/shell/completion.zsh index 8f7cecfa..6354e847 100644 --- a/shell/completion.zsh +++ b/shell/completion.zsh @@ -103,6 +103,7 @@ zsh\:"Zsh"))' \ '--no-info[Alias for --info=hidden]' \ '--inline-info[Alias for --info=inline]' \ '--border[Draw borders around the UI components]' \ +'--wrap[Wrap items in the item list]' \ '--read0[Read input delimited by ASCII NUL(\\0) characters]' \ '--print0[Print output delimited by ASCII NUL(\\0) characters]' \ '--print-query[Print the query as the first line]' \ diff --git a/tests/case.rs b/tests/case.rs index 371d9680..f152a4b0 100644 --- a/tests/case.rs +++ b/tests/case.rs @@ -5,51 +5,61 @@ mod common; use common::Keys::*; sk_test!(case_smart_lower, "aBcDeF", &["--case", "smart"], { + @capture[0] starts_with(">"); @keys Str("abc"); @capture[1] contains("1/1"); }); sk_test!(case_smart_exact, "aBcDeF", &["--case", "smart"], { + @capture[0] starts_with(">"); @keys Str("aBc"); @capture[1] contains("1/1"); }); sk_test!(case_smart_no_match, "aBcDeF", &["--case", "smart"], { + @capture[0] starts_with(">"); @keys Str("Abc"); @capture[1] contains("0/1"); }); sk_test!(case_ignore_lower, "aBcDeF", &["--case", "ignore"], { + @capture[0] starts_with(">"); @keys Str("abc"); @capture[1] contains("1/1"); }); sk_test!(case_ignore_exact, "aBcDeF", &["--case", "ignore"], { + @capture[0] starts_with(">"); @keys Str("aBc"); @capture[1] contains("1/1"); }); sk_test!(case_ignore_different, "aBcDeF", &["--case", "ignore"], { + @capture[0] starts_with(">"); @keys Str("Abc"); @capture[1] contains("1/1"); }); sk_test!(case_ignore_no_match, "aBcDeF", &["--case", "ignore"], { + @capture[0] starts_with(">"); @keys Str("z"); @capture[1] contains("0/1"); }); sk_test!(case_respect_lower, "aBcDeF", &["--case", "respect"], { + @capture[0] starts_with(">"); @keys Str("abc"); @capture[1] contains("0/1"); }); sk_test!(case_respect_exact, "aBcDeF", &["--case", "respect"], { + @capture[0] starts_with(">"); @keys Str("aBc"); @capture[1] contains("1/1"); }); sk_test!(case_respect_no_match, "aBcDeF", &["--case", "respect"], { + @capture[0] starts_with(">"); @keys Str("Abc"); @capture[1] contains("0/1"); }); diff --git a/tests/options.rs b/tests/options.rs index 4dc75669..358ee28f 100644 --- a/tests/options.rs +++ b/tests/options.rs @@ -712,9 +712,9 @@ sk_test!(opt_disabled, "a\\nb\\nc\\nd", &["--disabled"], { @capture[2] trim().starts_with("> a"); }); -sk_test!(opt_wrap, @cmd "seq -s',' 1 1000", &["--wrap"], { +sk_test!(opt_wrap, @cmd "seq -s',' 1 $COLUMNS", &["--wrap"], { @capture[0] starts_with(">"); @capture[1] trim().starts_with("1/1"); - @capture[2] ends_with(",1000"); + @capture[-1] trim().starts_with("> 1,"); @lines |l| (l.len() > 3); });