Skip to content

Commit 16410ac

Browse files
committed
res/void-docs: don't show picker for only 1 result
Makes for weird UX. This was implemented for fzf and skim with their '-1' flag, but it's pretty simple to add a general implementation that works for all pickers, including pick(1), which is what we ship with the void-docs-browse package. In addition, we can simplify the code by using head(1) as the fallback 'picker'. Bug reported and fixed by mason from IRC.
1 parent 304990b commit 16410ac

File tree

1 file changed

+4
-7
lines changed

1 file changed

+4
-7
lines changed

res/void-docs.in

Lines changed: 4 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -154,20 +154,17 @@ search_page() {
154154
return 0
155155
fi
156156

157-
_pager=
157+
_pager="head -1"
158158
if command -v fzf >/dev/null; then
159-
_pager="fzf -1"
159+
_pager=fzf
160160
elif command -v sk >/dev/null; then
161-
_pager="sk -1"
161+
_pager=sk
162162
elif command -v pick >/dev/null; then
163163
_pager=pick
164164
fi
165165

166-
if [ "$_pager" ]; then
166+
if [ $(IFS=' '; echo $file | wc -l) -gt 1 ]; then
167167
file="$(echo "$file" | $_pager)"
168-
[ -z "$file" ] && exit 1
169-
else
170-
file="$(echo "$file" | head -1)"
171168
fi
172169
file="${file%.md}"
173170
echo "$file"

0 commit comments

Comments
 (0)