feat: back to stable rust (#980)

* wip: stable rust, but no match indices

* feat: use restored indices api

* chore: use crates.io pushed 0.8.0

* chore: generate completions & manpage

* fix: remove nightly-specific coverage annotations

---------

Co-authored-by: Skim bot <skim-bot@skim-rs.github.io>
This commit is contained in:
LoricAndre 2026-02-19 20:53:05 +01:00 committed by GitHub
parent 1a90f4f52f
commit c7da16f167
No known key found for this signature in database
GPG key ID: B5690EEEBB952194
33 changed files with 106 additions and 137 deletions

View file

@ -2,6 +2,4 @@ set -xeuo pipefail
cargo fmt --check --all cargo fmt --check --all
cargo clippy --all-targets --features test-utils cargo clippy --all-targets --features test-utils
cargo +stable check --no-default-features cargo check --no-default-features
cargo +stable check --no-default-features --features cli
cargo check --no-default-features --features nightly-frizbee

View file

@ -113,11 +113,4 @@ jobs:
uses: Swatinem/rust-cache@v2 uses: Swatinem/rust-cache@v2
- name: Build without any feature - name: Build without any feature
run: | run: |
cargo +stable build --no-default-features cargo build --no-default-features
- name: Build with cli feature
run: |
cargo +stable build --no-default-features --features cli
- name: Build with frizbee feature
# Do not use +nightly to make sure we use the correct toolchain date
run: |
cargo build --no-default-features --features nightly-frizbee

45
Cargo.lock generated
View file

@ -903,12 +903,12 @@ checksum = "77ce24cb58228fbb8aa041425bb1050850ac19177686ea6e0f41a70416f56fdb"
[[package]] [[package]]
name = "frizbee" name = "frizbee"
version = "0.7.0" version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index" source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "4d024031f1a5bc5f19917baa0b618f1067610e35ba23e9f105653fcb27e74f5c" checksum = "e18c9ce192254be384afc9266228d57adf987a893a0dd61d049b1fca489c2e61"
dependencies = [ dependencies = [
"multiversion", "itertools 0.14.0",
"rayon", "raw-cpuid",
] ]
[[package]] [[package]]
@ -1375,28 +1375,6 @@ dependencies = [
"windows-sys 0.61.2", "windows-sys 0.61.2",
] ]
[[package]]
name = "multiversion"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "7edb7f0ff51249dfda9ab96b5823695e15a052dc15074c9dbf3d118afaf2c201"
dependencies = [
"multiversion-macros",
"target-features",
]
[[package]]
name = "multiversion-macros"
version = "0.8.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "b093064383341eb3271f42e381cb8f10a01459478446953953c75d24bd339fc0"
dependencies = [
"proc-macro2",
"quote",
"syn 2.0.116",
"target-features",
]
[[package]] [[package]]
name = "nix" name = "nix"
version = "0.28.0" version = "0.28.0"
@ -1896,6 +1874,15 @@ dependencies = [
"unicode-width", "unicode-width",
] ]
[[package]]
name = "raw-cpuid"
version = "11.6.0"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "498cd0dc59d73224351ee52a95fee0f1a617a2eae0e7d9d720cc622c73a54186"
dependencies = [
"bitflags 2.11.0",
]
[[package]] [[package]]
name = "rayon" name = "rayon"
version = "1.11.0" version = "1.11.0"
@ -2324,12 +2311,6 @@ dependencies = [
"unicode-ident", "unicode-ident",
] ]
[[package]]
name = "target-features"
version = "0.1.6"
source = "registry+https://github.com/rust-lang/crates.io-index"
checksum = "c1bbb9f3c5c463a01705937a24fdabc5047929ac764b2d5b9cf681c1f5041ed5"
[[package]] [[package]]
name = "tempfile" name = "tempfile"
version = "3.25.0" version = "3.25.0"

View file

@ -62,7 +62,7 @@ clap_complete_nushell = "4.5.10"
interprocess = { version = "2.3.1", features = ["tokio"] } interprocess = { version = "2.3.1", features = ["tokio"] }
serde = { version = "1.0.228", features = ["derive"] } serde = { version = "1.0.228", features = ["derive"] }
ron = "0.12.0" ron = "0.12.0"
frizbee = { version = "0.7.0", optional = true } frizbee = { version = "0.8.0" }
roff = "1.0.0" roff = "1.0.0"
unicode-display-width = "0.3.0" unicode-display-width = "0.3.0"
unicode-normalization = "0.1.25" unicode-normalization = "0.1.25"
@ -72,11 +72,9 @@ tui-term = "0.3.1"
kanal = "0.1.1" kanal = "0.1.1"
[features] [features]
default = ["cli", "nightly-frizbee"] default = ["cli"]
# Everyting needed to use skim as a cli (argument parsing, shell integrations...) # Everyting needed to use skim as a cli (argument parsing, shell integrations...)
cli = ["dep:clap", "dep:clap_complete", "dep:shlex", "dep:env_logger", "dep:clap_mangen"] cli = ["dep:clap", "dep:clap_complete", "dep:shlex", "dep:env_logger", "dep:clap_mangen"]
# The frizbee matcher, which requires cargo nightly
nightly-frizbee = ["dep:frizbee"]
# Enable test utilities (e.g., Tui::new_for_test) # Enable test utilities (e.g., Tui::new_for_test)
test-utils = [] test-utils = []

View file

@ -102,9 +102,7 @@ Any of the following applies:
$ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/skim-rs/skim/releases/latest/download/skim-installer.sh | sh $ curl --proto '=https' --tlsv1.2 -LsSf https://github.com/skim-rs/skim/releases/latest/download/skim-installer.sh | sh
``` ```
- Using Binary: Simply [download the sk executable](https://github.com/skim-rs/skim/releases) directly. - Using Binary: Simply [download the sk executable](https://github.com/skim-rs/skim/releases) directly.
- Install from [crates.io](https://crates.io/): - Install from [crates.io](https://crates.io/): `cargo install skim`
- For the frizbee typo-resistant matcher, we need nightly rust: `cargo +nightly-2026-02-11 install skim` (run `rustup toolchain install nightly-2026-02-11` if needed)
- Otherwise, use `cargo install skim --no-default-features --features cli`
- Build Manually: - Build Manually:
```sh ```sh
$ git clone --depth 1 git@github.com:skim-rs/skim.git ~/.skim $ git clone --depth 1 git@github.com:skim-rs/skim.git ~/.skim
@ -521,7 +519,6 @@ skim = { version = "<version>", default-features = false, features = [..] }
_Note on features_: _Note on features_:
- the `cli` feature is required to use skim as a cli, it *should* not be needed when using it as a library. - the `cli` feature is required to use skim as a cli, it *should* not be needed when using it as a library.
- the `nightly-frizbee` feature adds the frizbee algorithm, but requires cargo nigthly.
### Basic usage ### Basic usage

View file

@ -8,7 +8,7 @@ sk \- Fuzzy Finder in rust!
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.SH SYNOPSIS .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\-\-normalize\fR] [\fB\-\-split\-match\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\-\-no\-strip\-ansi\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\-\-remote\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\-\-normalize\fR] [\fB\-\-split\-match\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\-\-print\-current\fR] [\fB\-\-output\-format\fR] [\fB\-\-no\-strip\-ansi\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\-\-remote\fR] [\fB\-\-tmux\fR] [\fB\-\-log\-file\fR] [\fB\-\-expect\fR] [\fB\-h\fR|\fB\-\-help\fR] [\fB\-V\fR|\fB\-\-version\fR]
.ie \n(.g .ds Aq \(aq .ie \n(.g .ds Aq \(aq
.el .ds Aq ' .el .ds Aq '
.SH OPTIONS .SH OPTIONS
@ -455,6 +455,12 @@ Print the score after each item
\fB\-\-print\-header\fR \fB\-\-print\-header\fR
Print the header as the first line (after print\-score) Print the header as the first line (after print\-score)
.TP .TP
\fB\-\-print\-current\fR
Print the current (highlighted) item as the first line (after print\-header)
.TP
\fB\-\-output\-format\fR \fI<OUTPUT_FORMAT>\fR
Set the output format If set, overrides all print_ options Will be expanded the same way as preview or commands
.TP
\fB\-\-no\-strip\-ansi\fR \fB\-\-no\-strip\-ansi\fR
Print the ANSI codes, making the output exactly match the input even when \-\-ansi is on Print the ANSI codes, making the output exactly match the input even when \-\-ansi is on
.TP .TP

View file

@ -1,4 +1,4 @@
[toolchain] [toolchain]
channel = "nightly-2026-02-11" channel = "stable"
profile = "default" profile = "default"
components = ["rust-analyzer"] components = ["rust-analyzer"]

View file

@ -23,7 +23,7 @@ _sk() {
case "${cmd}" in case "${cmd}" in
sk) 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 --normalize --split-match --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 --no-strip-ansi --select-1 --exit-0 --sync --pre-select-n --pre-select-pat --pre-select-items --pre-select-file --filter --shell --shell-bindings --man --listen --remote --tmux --log-file --flags --extended --literal --hscroll-off --filepath-word --jump-labels --no-bold --phony --scheme --tail --style --no-color --padding --border-label --border-label-pos --highlight-line --wrap-sign --no-multi-line --raw --track --gap --gap-line --freeze-left --freeze-right --scroll-off --gutter --gutter-raw --marker-multi-line --ellipsis --scrollbar --no-scrollbar --list-border --list-label --list-label-pos --no-input --info-command --separator --no-separator --ghost --input-border --input-label --input-label-pos --preview-label --preview-label-pos --header-first --header-border --header-lines-border --footer --footer-border --footer-label --footer-label-pos --with-shell --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 --normalize --split-match --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 --ellipsis --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 --print-current --output-format --no-strip-ansi --select-1 --exit-0 --sync --pre-select-n --pre-select-pat --pre-select-items --pre-select-file --filter --shell --shell-bindings --man --listen --remote --tmux --log-file --flags --extended --literal --hscroll-off --filepath-word --jump-labels --no-bold --phony --scheme --tail --style --no-color --padding --border-label --border-label-pos --highlight-line --wrap-sign --no-multi-line --raw --track --gap --gap-line --freeze-left --freeze-right --scroll-off --gutter --gutter-raw --marker-multi-line --scrollbar --no-scrollbar --list-border --list-label --list-label-pos --no-input --info-command --separator --no-separator --ghost --input-border --input-label --input-label-pos --preview-label --preview-label-pos --header-first --header-border --header-lines-border --footer --footer-border --footer-label --footer-label-pos --with-shell --expect --help --version"
if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then if [[ ${cur} == -* || ${COMP_CWORD} -eq 1 ]] ; then
COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") ) COMPREPLY=( $(compgen -W "${opts}" -- "${cur}") )
return 0 return 0
@ -141,6 +141,10 @@ _sk() {
COMPREPLY=($(compgen -f "${cur}")) COMPREPLY=($(compgen -f "${cur}"))
return 0 return 0
;; ;;
--ellipsis)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--info) --info)
COMPREPLY=($(compgen -W "default inline hidden" -- "${cur}")) COMPREPLY=($(compgen -W "default inline hidden" -- "${cur}"))
return 0 return 0
@ -193,6 +197,10 @@ _sk() {
COMPREPLY=($(compgen -f "${cur}")) COMPREPLY=($(compgen -f "${cur}"))
return 0 return 0
;; ;;
--output-format)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--pre-select-n) --pre-select-n)
COMPREPLY=($(compgen -f "${cur}")) COMPREPLY=($(compgen -f "${cur}"))
return 0 return 0
@ -309,10 +317,6 @@ _sk() {
COMPREPLY=($(compgen -f "${cur}")) COMPREPLY=($(compgen -f "${cur}"))
return 0 return 0
;; ;;
--ellipsis)
COMPREPLY=($(compgen -f "${cur}"))
return 0
;;
--scrollbar) --scrollbar)
COMPREPLY=($(compgen -f "${cur}")) COMPREPLY=($(compgen -f "${cur}"))
return 0 return 0

View file

@ -36,6 +36,7 @@ complete -c sk -l cmd-prompt -d 'Set prompt in command mode' -r
complete -c sk -l selector -d 'Set selected item icon' -r complete -c sk -l selector -d 'Set selected item icon' -r
complete -c sk -l multi-selector -d 'Set selected item icon' -r complete -c sk -l multi-selector -d 'Set selected item icon' -r
complete -c sk -l tabstop -d 'Number of spaces that make up a tab' -r complete -c sk -l tabstop -d 'Number of spaces that make up a tab' -r
complete -c sk -l ellipsis -d 'The characters used to display truncated lines' -r
complete -c sk -l info -d 'Set matching result count display position' -r -f -a "default\t'' complete -c sk -l info -d 'Set matching result count display position' -r -f -a "default\t''
inline\t'' inline\t''
hidden\t''" hidden\t''"
@ -61,6 +62,7 @@ complete -c sk -l preview -d 'Preview command' -r
complete -c sk -l preview-window -d 'Preview window layout' -r complete -c sk -l preview-window -d 'Preview window layout' -r
complete -c sk -s q -l query -d 'Initial query' -r complete -c sk -s q -l query -d 'Initial query' -r
complete -c sk -l cmd-query -d 'Initial query in interactive mode' -r complete -c sk -l cmd-query -d 'Initial query in interactive mode' -r
complete -c sk -l output-format -d 'Set the output format If set, overrides all print_ options Will be expanded the same way as preview or commands' -r
complete -c sk -l pre-select-n -d 'Pre-select the first n items in multi-selection mode' -r complete -c sk -l pre-select-n -d 'Pre-select the first n items in multi-selection mode' -r
complete -c sk -l pre-select-pat -d 'Pre-select the matched items in multi-selection mode' -r complete -c sk -l pre-select-pat -d 'Pre-select the matched items in multi-selection mode' -r
complete -c sk -l pre-select-items -d 'Pre-select the items separated by newline character' -r complete -c sk -l pre-select-items -d 'Pre-select the items separated by newline character' -r
@ -94,7 +96,6 @@ complete -c sk -l scroll-off -r
complete -c sk -l gutter -r complete -c sk -l gutter -r
complete -c sk -l gutter-raw -r complete -c sk -l gutter-raw -r
complete -c sk -l marker-multi-line -r complete -c sk -l marker-multi-line -r
complete -c sk -l ellipsis -r
complete -c sk -l scrollbar -r complete -c sk -l scrollbar -r
complete -c sk -l list-border -r complete -c sk -l list-border -r
complete -c sk -l list-label -r complete -c sk -l list-label -r
@ -144,6 +145,7 @@ complete -c sk -l print-query -d 'Print the query as the first line'
complete -c sk -l print-cmd -d 'Print the command as the first line (after print-query)' complete -c sk -l print-cmd -d 'Print the command as the first line (after print-query)'
complete -c sk -l print-score -d 'Print the score after each item' complete -c sk -l print-score -d 'Print the score after each item'
complete -c sk -l print-header -d 'Print the header as the first line (after print-score)' complete -c sk -l print-header -d 'Print the header as the first line (after print-score)'
complete -c sk -l print-current -d 'Print the current (highlighted) item as the first line (after print-header)'
complete -c sk -l no-strip-ansi -d 'Print the ANSI codes, making the output exactly match the input even when --ansi is on' complete -c sk -l no-strip-ansi -d 'Print the ANSI codes, making the output exactly match the input even when --ansi is on'
complete -c sk -s 1 -l select-1 -d 'Do not enter the TUI if the query passed in -q matches only one item and return it' complete -c sk -s 1 -l select-1 -d 'Do not enter the TUI if the query passed in -q matches only one item and return it'
complete -c sk -s 0 -l exit-0 -d 'Do not enter the TUI if the query passed in -q does not match any item' complete -c sk -s 0 -l exit-0 -d 'Do not enter the TUI if the query passed in -q does not match any item'

View file

@ -76,6 +76,7 @@ module completions {
--multi-selector: string # Set selected item icon --multi-selector: string # Set selected item icon
--ansi # Parse ANSI color codes in input strings --ansi # Parse ANSI color codes in input strings
--tabstop: string # Number of spaces that make up a tab --tabstop: string # Number of spaces that make up a tab
--ellipsis: string # The characters used to display truncated lines
--info: string@"nu-complete sk info" # Set matching result count display position --info: string@"nu-complete sk info" # Set matching result count display position
--no-info # Alias for --info=hidden --no-info # Alias for --info=hidden
--inline-info # Alias for --info=inline --inline-info # Alias for --info=inline
@ -97,6 +98,8 @@ module completions {
--print-cmd # Print the command as the first line (after print-query) --print-cmd # Print the command as the first line (after print-query)
--print-score # Print the score after each item --print-score # Print the score after each item
--print-header # Print the header as the first line (after print-score) --print-header # Print the header as the first line (after print-score)
--print-current # Print the current (highlighted) item as the first line (after print-header)
--output-format: string # Set the output format If set, overrides all print_ options Will be expanded the same way as preview or commands
--no-strip-ansi # Print the ANSI codes, making the output exactly match the input even when --ansi is on --no-strip-ansi # Print the ANSI codes, making the output exactly match the input even when --ansi is on
--select-1(-1) # Do not enter the TUI if the query passed in -q matches only one item and return it --select-1(-1) # Do not enter the TUI if the query passed in -q matches only one item and return it
--exit-0(-0) # Do not enter the TUI if the query passed in -q does not match any item --exit-0(-0) # Do not enter the TUI if the query passed in -q does not match any item
@ -141,7 +144,6 @@ module completions {
--gutter: string --gutter: string
--gutter-raw: string --gutter-raw: string
--marker-multi-line: string --marker-multi-line: string
--ellipsis: string
--scrollbar: string --scrollbar: string
--no-scrollbar --no-scrollbar
--list-border: string --list-border: string

View file

@ -50,6 +50,7 @@ reverse-list\:"Display from the top of the screen, prompt at the bottom"))' \
'--selector=[Set selected item icon]:SELECTOR_ICON:_default' \ '--selector=[Set selected item icon]:SELECTOR_ICON:_default' \
'--multi-selector=[Set selected item icon]:MULTI_SELECT_ICON:_default' \ '--multi-selector=[Set selected item icon]:MULTI_SELECT_ICON:_default' \
'--tabstop=[Number of spaces that make up a tab]:TABSTOP:_default' \ '--tabstop=[Number of spaces that make up a tab]:TABSTOP:_default' \
'--ellipsis=[The characters used to display truncated lines]:ELLIPSIS:_default' \
'--info=[Set matching result count display position]:INFO:(default inline hidden)' \ '--info=[Set matching result count display position]:INFO:(default inline hidden)' \
'--header=[Set header, displayed next to the info]:HEADER:_default' \ '--header=[Set header, displayed next to the info]:HEADER:_default' \
'--header-lines=[Number of lines of the input treated as header]:HEADER_LINES:_default' \ '--header-lines=[Number of lines of the input treated as header]:HEADER_LINES:_default' \
@ -63,6 +64,7 @@ reverse-list\:"Display from the top of the screen, prompt at the bottom"))' \
'-q+[Initial query]:QUERY:_default' \ '-q+[Initial query]:QUERY:_default' \
'--query=[Initial query]:QUERY:_default' \ '--query=[Initial query]:QUERY:_default' \
'--cmd-query=[Initial query in interactive mode]:CMD_QUERY:_default' \ '--cmd-query=[Initial query in interactive mode]:CMD_QUERY:_default' \
'--output-format=[Set the output format If set, overrides all print_ options Will be expanded the same way as preview or commands]:OUTPUT_FORMAT:_default' \
'--pre-select-n=[Pre-select the first n items in multi-selection mode]:PRE_SELECT_N:_default' \ '--pre-select-n=[Pre-select the first n items in multi-selection mode]:PRE_SELECT_N:_default' \
'--pre-select-pat=[Pre-select the matched items in multi-selection mode]:PRE_SELECT_PAT:_default' \ '--pre-select-pat=[Pre-select the matched items in multi-selection mode]:PRE_SELECT_PAT:_default' \
'--pre-select-items=[Pre-select the items separated by newline character]:PRE_SELECT_ITEMS:_default' \ '--pre-select-items=[Pre-select the items separated by newline character]:PRE_SELECT_ITEMS:_default' \
@ -97,7 +99,6 @@ zsh\:"Zsh"))' \
'--gutter=[]:GUTTER:_default' \ '--gutter=[]:GUTTER:_default' \
'--gutter-raw=[]:GUTTER_RAW:_default' \ '--gutter-raw=[]:GUTTER_RAW:_default' \
'--marker-multi-line=[]:MARKER_MULTI_LINE:_default' \ '--marker-multi-line=[]:MARKER_MULTI_LINE:_default' \
'--ellipsis=[]:ELLIPSIS:_default' \
'--scrollbar=[]:SCROLLBAR:_default' \ '--scrollbar=[]:SCROLLBAR:_default' \
'--list-border=[]:LIST_BORDER:_default' \ '--list-border=[]:LIST_BORDER:_default' \
'--list-label=[]:LIST_LABEL:_default' \ '--list-label=[]:LIST_LABEL:_default' \
@ -150,6 +151,7 @@ zsh\:"Zsh"))' \
'--print-cmd[Print the command as the first line (after print-query)]' \ '--print-cmd[Print the command as the first line (after print-query)]' \
'--print-score[Print the score after each item]' \ '--print-score[Print the score after each item]' \
'--print-header[Print the header as the first line (after print-score)]' \ '--print-header[Print the header as the first line (after print-score)]' \
'--print-current[Print the current (highlighted) item as the first line (after print-header)]' \
'--no-strip-ansi[Print the ANSI codes, making the output exactly match the input even when --ansi is on]' \ '--no-strip-ansi[Print the ANSI codes, making the output exactly match the input even when --ansi is on]' \
'-1[Do not enter the TUI if the query passed in -q matches only one item and return it]' \ '-1[Do not enter the TUI if the query passed in -q matches only one item and return it]' \
'--select-1[Do not enter the TUI if the query passed in -q matches only one item and return it]' \ '--select-1[Do not enter the TUI if the query passed in -q matches only one item and return it]' \

View file

@ -235,7 +235,6 @@ pub fn parse_keymap(key_action: &str) -> Result<(&str, Vec<Action>)> {
} }
#[cfg(test)] #[cfg(test)]
#[cfg_attr(coverage, coverage(off))]
mod tests { mod tests {
use super::*; use super::*;
use event::Action::*; use event::Action::*;

View file

@ -1,4 +1,3 @@
#![cfg_attr(coverage, coverage(off))]
//! Provides helpers to easily generate shell completions //! Provides helpers to easily generate shell completions
use clap::CommandFactory; use clap::CommandFactory;

View file

@ -226,7 +226,6 @@ impl MatchEngineFactory for RegexEngineFactory {
} }
#[cfg(test)] #[cfg(test)]
#[cfg_attr(coverage, coverage(off))]
mod test { mod test {
#[test] #[test]
fn test_engine_factory() { fn test_engine_factory() {

View file

@ -2,7 +2,6 @@ use std::cmp::min;
use std::fmt::{Display, Error, Formatter}; use std::fmt::{Display, Error, Formatter};
use std::sync::Arc; use std::sync::Arc;
#[cfg(feature = "nightly-frizbee")]
use crate::fuzzy_matcher::frizbee::FrizbeeMatcher; use crate::fuzzy_matcher::frizbee::FrizbeeMatcher;
use crate::fuzzy_matcher::{FuzzyMatcher, IndexType, ScoreType, clangd::ClangdMatcher, skim::SkimMatcherV2}; use crate::fuzzy_matcher::{FuzzyMatcher, IndexType, ScoreType, clangd::ClangdMatcher, skim::SkimMatcherV2};
@ -66,11 +65,6 @@ impl FuzzyEngineBuilder {
use crate::fuzzy_matcher::skim::SkimMatcher; use crate::fuzzy_matcher::skim::SkimMatcher;
#[allow(unused_mut)] #[allow(unused_mut)]
let mut algorithm = self.algorithm; let mut algorithm = self.algorithm;
#[cfg(not(feature = "nightly-frizbee"))]
if algorithm == FuzzyAlgorithm::Frizbee {
warn!("Frizbee algorithm not enabled, using SkimV2");
algorithm = FuzzyAlgorithm::SkimV2;
}
let matcher: Box<dyn FuzzyMatcher> = match algorithm { let matcher: Box<dyn FuzzyMatcher> = match algorithm {
FuzzyAlgorithm::SkimV1 => { FuzzyAlgorithm::SkimV1 => {
debug!("Initialized SkimV1 algorithm"); debug!("Initialized SkimV1 algorithm");
@ -96,12 +90,7 @@ impl FuzzyEngineBuilder {
debug!("Initialized Clangd algorithm"); debug!("Initialized Clangd algorithm");
Box::new(matcher) Box::new(matcher)
} }
FuzzyAlgorithm::Frizbee => { FuzzyAlgorithm::Frizbee => Box::new(FrizbeeMatcher { case: self.case }),
#[cfg(not(feature = "nightly-frizbee"))]
unreachable!();
#[cfg(feature = "nightly-frizbee")]
Box::new(FrizbeeMatcher::default())
}
}; };
FuzzyEngine { FuzzyEngine {

View file

@ -179,7 +179,6 @@ pub fn parse_transform_fields(delimiter: &Regex, text: &str, fields: &[FieldRang
} }
#[cfg(test)] #[cfg(test)]
#[cfg_attr(coverage, coverage(off))]
mod test { mod test {
use super::FieldRange::*; use super::FieldRange::*;
#[test] #[test]

View file

@ -452,7 +452,6 @@ fn print_dp(line: &str, pattern: &str, dp: &[Vec<Score>]) {
} }
#[cfg(test)] #[cfg(test)]
#[cfg_attr(coverage, coverage(off))]
mod tests { mod tests {
use super::*; use super::*;
use crate::fuzzy_matcher::util::{assert_order, wrap_matches}; use crate::fuzzy_matcher::util::{assert_order, wrap_matches};

View file

@ -1,37 +1,57 @@
//! Matcher using https://crates.io/crates/frizbee //! Matcher using https://crates.io/crates/frizbee
use frizbee::{Config, Scoring, match_indices}; use frizbee::{Scoring, smith_waterman::simd::SmithWatermanMatcher};
use crate::fuzzy_matcher::{FuzzyMatcher, IndexType, ScoreType}; use crate::{
CaseMatching,
fuzzy_matcher::{FuzzyMatcher, IndexType, ScoreType},
};
const RESPECT_CASE_BONUS: u16 = 10000;
/// Matcher using frizbee, /// Matcher using frizbee,
/// the same one that `blink.cmp` uses in neovim /// the same one that `blink.cmp` uses in neovim
/// credits to @saghen /// credits to @saghen
#[derive(Default)] #[derive(Default)]
pub struct FrizbeeMatcher {} pub struct FrizbeeMatcher {
/// The case for matching
fn adaptive(pattern: &str) -> Config { /// Will be translated into a matching_case_bonus
Config { pub case: CaseMatching,
max_typos: Some(pattern.chars().count().saturating_div(4).try_into().unwrap()),
prefilter: true,
sort: false,
scoring: Scoring::default(),
}
} }
impl FuzzyMatcher for FrizbeeMatcher { impl FuzzyMatcher for FrizbeeMatcher {
fn fuzzy_indices(&self, choice: &str, pattern: &str) -> Option<(ScoreType, Vec<IndexType>)> { fn fuzzy_indices(&self, choice: &str, pattern: &str) -> Option<(ScoreType, Vec<IndexType>)> {
let matches = match_indices(pattern, choice, &adaptive(pattern))?; let max_typos: u16 = pattern.chars().count().saturating_div(4).try_into().unwrap();
let scoring = Scoring {
let mut indices = Vec::new(); matching_case_bonus: match self.case {
for matched_idx in matches.indices { CaseMatching::Respect => RESPECT_CASE_BONUS,
for (char_idx, (byte_idx, _)) in choice.char_indices().enumerate() { CaseMatching::Ignore => 0,
if byte_idx == matched_idx { CaseMatching::Smart => {
indices.push(char_idx); if pattern.chars().any(|c| c.is_uppercase()) {
break; RESPECT_CASE_BONUS
} else {
0
}
} }
} },
} ..Default::default()
};
Some((matches.score.into(), indices)) let mut matcher = SmithWatermanMatcher::new(pattern.as_bytes(), &scoring);
matcher
.match_haystack_indices(choice.as_bytes(), 0, Some(max_typos))
.and_then(|(m, indices)| {
debug!("{choice}: {m} ({})", scoring.matching_case_bonus);
if m > scoring.matching_case_bonus.saturating_mul(
pattern
.chars()
.count()
.saturating_sub(max_typos as usize)
.try_into()
.unwrap(),
) {
Some((m.into(), indices))
} else {
None
}
})
} }
} }

View file

@ -5,7 +5,6 @@
/// Clangd fuzzy matching algorithm /// Clangd fuzzy matching algorithm
pub mod clangd; pub mod clangd;
#[cfg(feature = "nightly-frizbee")]
pub mod frizbee; pub mod frizbee;
/// Skim fuzzy matching algorithm /// Skim fuzzy matching algorithm
pub mod skim; pub mod skim;

View file

@ -1043,7 +1043,6 @@ impl FuzzyMatcher for SkimMatcherV2 {
} }
#[cfg(test)] #[cfg(test)]
#[cfg_attr(coverage, coverage(off))]
mod tests { mod tests {
use crate::fuzzy_matcher::util::{assert_order, wrap_matches}; use crate::fuzzy_matcher::util::{assert_order, wrap_matches};

View file

@ -537,7 +537,6 @@ fn escape_ansi(raw: &str) -> String {
} }
#[cfg(test)] #[cfg(test)]
#[cfg_attr(coverage, coverage(off))]
mod test { mod test {
use super::*; use super::*;

View file

@ -67,7 +67,6 @@ impl Selector for DefaultSkimSelector {
} }
#[cfg(test)] #[cfg(test)]
#[cfg_attr(coverage, coverage(off))]
mod tests { mod tests {
use super::*; use super::*;

View file

@ -22,7 +22,6 @@
//! let output = Skim::run_with(options, Some(items)).unwrap(); //! let output = Skim::run_with(options, Some(items)).unwrap();
//! ``` //! ```
#![warn(missing_docs)] #![warn(missing_docs)]
#![cfg_attr(coverage, feature(coverage_attribute))]
#[macro_use] #[macro_use]
extern crate log; extern crate log;

View file

@ -1,4 +1,3 @@
#![cfg_attr(coverage, coverage(off))]
//! Provides what's needed to generate skim's man page //! Provides what's needed to generate skim's man page
use std::io::Write; use std::io::Write;

View file

@ -85,7 +85,6 @@ impl<T: ?Sized> Drop for SpinLockGuard<'_, T> {
} }
#[cfg(test)] #[cfg(test)]
#[cfg_attr(coverage, coverage(off))]
mod tests { mod tests {
use super::*; use super::*;
use std::sync::Arc; use std::sync::Arc;

View file

@ -321,17 +321,15 @@ impl ColorTheme {
let g = u8::from_str_radix(&raw_color[3..5], 16).unwrap_or(255); let g = u8::from_str_radix(&raw_color[3..5], 16).unwrap_or(255);
let b = u8::from_str_radix(&raw_color[5..7], 16).unwrap_or(255); let b = u8::from_str_radix(&raw_color[5..7], 16).unwrap_or(255);
Some(Color::Rgb(r, g, b)) Some(Color::Rgb(r, g, b))
} else if raw_color == "-1" {
Some(Color::Reset)
} else { } else {
if raw_color == "-1" { raw_color.parse::<u8>().ok().map(Color::Indexed).or_else(|| {
Some(Color::Reset) if !raw_color.is_empty() {
} else { debug!("Unknown color '{}'", spec_parts[0]);
raw_color.parse::<u8>().ok().map(Color::Indexed).or_else(|| { }
if !raw_color.is_empty() { None
debug!("Unknown color '{}'", spec_parts[0]); })
}
None
})
}
}; };
let layer_override = if component_name == "bg+" { "bg" } else { layer }; let layer_override = if component_name == "bg+" { "bg" } else { layer };
@ -379,7 +377,6 @@ fn set_style(s: &mut Style, layer: &str, color: Option<Color>, modifier: Modifie
} }
#[cfg(test)] #[cfg(test)]
#[cfg_attr(coverage, coverage(off))]
mod tests { mod tests {
use super::*; use super::*;

View file

@ -358,7 +358,6 @@ fn sanitize_value(value: String) -> String {
} }
#[cfg(test)] #[cfg(test)]
#[cfg_attr(coverage, coverage(off))]
mod tests { mod tests {
use super::*; use super::*;

View file

@ -104,7 +104,6 @@ where
/// raw mode, scrolling) that don't work with `TestBackend`. Use this when /// raw mode, scrolling) that don't work with `TestBackend`. Use this when
/// writing snapshot tests or other tests that need to render the UI. /// writing snapshot tests or other tests that need to render the UI.
#[cfg(any(test, feature = "test-utils"))] #[cfg(any(test, feature = "test-utils"))]
#[cfg_attr(coverage, coverage(off))]
pub fn new_for_test(backend: B) -> Result<Self> { pub fn new_for_test(backend: B) -> Result<Self> {
let event_channel = channel(1024 * 1024); let event_channel = channel(1024 * 1024);
Ok(Self { Ok(Self {

View file

@ -152,7 +152,6 @@ impl From<BorderType> for ratatui::widgets::BorderType {
} }
#[cfg(test)] #[cfg(test)]
#[cfg_attr(coverage, coverage(off))]
mod size_test { mod size_test {
use super::*; use super::*;
use std::num::IntErrorKind; use std::num::IntErrorKind;

View file

@ -88,7 +88,6 @@ impl From<&str> for PreviewLayout {
// } // }
#[cfg(test)] #[cfg(test)]
#[cfg_attr(coverage, coverage(off))]
mod tests { mod tests {
use super::*; use super::*;

View file

@ -275,7 +275,6 @@ pub(crate) fn cursor_pos_from_tty() -> io::Result<(u16, u16)> {
} }
#[cfg(test)] #[cfg(test)]
#[cfg_attr(coverage, coverage(off))]
mod tests { mod tests {
use super::*; use super::*;
use ansi_to_tui::IntoText as _; use ansi_to_tui::IntoText as _;

View file

@ -201,15 +201,13 @@ pub fn printf(
log::warn!("Failed to build multi-item field range from {content}"); log::warn!("Failed to build multi-item field range from {content}");
replaced.push_str(&format!("{{{s}}}")); replaced.push_str(&format!("{{{s}}}"));
} }
} else if let Some(range) = FieldRange::from_str(stripped) {
let replacement =
get_string_by_field(delimiter, &item_text, &range).unwrap_or_default();
replaced.push_str(&escape_arg(replacement, true));
} else { } else {
if let Some(range) = FieldRange::from_str(stripped) { log::warn!("Failed to build field range from {content}");
let replacement = replaced.push_str(&format!("{{{s}}}"));
get_string_by_field(delimiter, &item_text, &range).unwrap_or_default();
replaced.push_str(&escape_arg(replacement, true));
} else {
log::warn!("Failed to build field range from {content}");
replaced.push_str(&format!("{{{s}}}"));
}
} }
} }
} }
@ -238,7 +236,6 @@ pub fn printf(
} }
#[cfg(test)] #[cfg(test)]
#[cfg_attr(coverage, coverage(off))]
mod test { mod test {
use super::*; use super::*;
use crate::SkimItem; use crate::SkimItem;

View file

@ -2,16 +2,15 @@
source: tests/matcher.rs source: tests/matcher.rs
expression: buf + & cursor_pos expression: buf + & cursor_pos
--- ---
" src/helper/item_reader.rs " " src/skim_item.rs "
" src/output.rs "
" src/item.rs "
" src/fuzzy_matcher/clangd.rs " " src/fuzzy_matcher/clangd.rs "
" src/fuzzy_matcher/frizbee.rs " " src/fuzzy_matcher/frizbee.rs "
" src/fuzzy_matcher/skim.rs " " src/fuzzy_matcher/skim.rs "
" src/fuzzy_matcher/util.rs " " src/fuzzy_matcher/util.rs "
" src/fuzzy_matcher/mod.rs " " src/fuzzy_matcher/mod.rs "
" src/output.rs "
" src/theme.rs " " src/theme.rs "
" src/item.rs "
" src/tmux.rs "
" src/tui/header.rs " " src/tui/header.rs "
" src/tui/statusline.rs " " src/tui/statusline.rs "
" src/tui/input.rs " " src/tui/input.rs "
@ -22,6 +21,7 @@ expression: buf + & cursor_pos
" src/tui/widget.rs " " src/tui/widget.rs "
" src/tui/options.rs " " src/tui/options.rs "
" src/tui/util.rs " " src/tui/util.rs "
" src/tmux.rs "
" src/tui/item_list.rs " " src/tui/item_list.rs "
"> src/tui/mod.rs " "> src/tui/mod.rs "
" 24/49 0/0" " 24/49 0/0"