Skip to content

Commit

Permalink
fix(ui): pad preview columns to prevent word wrap weirdness
Browse files Browse the repository at this point in the history
Add a couple extra columns when telling gh the width of the fzf preview
window. This seems to prevent some off-by-one issue that caused words to
wrap in in weird places.
  • Loading branch information
benelan committed Jul 21, 2024
1 parent e944671 commit 79cbd4b
Showing 1 changed file with 11 additions and 8 deletions.
19 changes: 11 additions & 8 deletions gh-fzf
Original file line number Diff line number Diff line change
Expand Up @@ -146,6 +146,9 @@ else
GH_COLUMNS='9999999'
fi

# set shell so bash features can be used in subshells created by fzf
export SHELL="bash"

GH_STATUS="$(github_status)"
[ "$GH_STATUS" == "All Systems Operational" ] && GH_STATUS="" ||
GH_STATUS=" GitHub Service Alert: $GH_STATUS "
Expand Down Expand Up @@ -187,7 +190,7 @@ default_cmd() {
cmd="api"
printf "%s\n\n" "There is no \`gh milestone\` command so \`gh api\` is used:"
fi
GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh help $cmd
GH_FORCE_TTY=$((FZF_PREVIEW_COLUMNS-3)) gh help $cmd
' \
--preview-window='right:75%,wrap' \
--bind="enter:execute(gh fzf {})"
Expand Down Expand Up @@ -243,7 +246,7 @@ $global_binds
# FZF COMMAND {{{2
FZF_DEFAULT_COMMAND="GH_FORCE_TTY=$GH_COLUMNS gh issue list $issue_template -L $GH_FZF_DEFAULT_LIMIT $*" \
fzf \
--preview='GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh issue view {1} --comments '"$REPO_FLAG" \
--preview='GH_FORCE_TTY=$((FZF_PREVIEW_COLUMNS-3)) gh issue view {1} --comments '"$REPO_FLAG" \
--prompt="issue ❱ " \
--header="$issue_header" \
--bind="start:${GH_FZF_HIDE_HINTS:+"toggle-header"}" \
Expand Down Expand Up @@ -327,7 +330,7 @@ $global_binds
# FZF COMMAND {{{2
FZF_DEFAULT_COMMAND="GH_FORCE_TTY=$GH_COLUMNS gh pr list $pr_template -L $GH_FZF_DEFAULT_LIMIT $*" \
fzf \
--preview='GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh pr view {1} --comments '"$REPO_FLAG" \
--preview='GH_FORCE_TTY=$((FZF_PREVIEW_COLUMNS-3)) gh pr view {1} --comments '"$REPO_FLAG" \
--prompt="pr ❱ " \
--header="$pr_header" \
--bind="start:${GH_FZF_HIDE_HINTS:+"toggle-header"}" \
Expand Down Expand Up @@ -420,7 +423,7 @@ $global_binds
# FZF COMMAND {{{2
FZF_DEFAULT_COMMAND="GH_FORCE_TTY=$GH_COLUMNS gh run list $run_template -L $GH_FZF_DEFAULT_LIMIT $*" \
fzf \
--preview='GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh run view {-1} '"$REPO_FLAG" \
--preview='GH_FORCE_TTY=$((FZF_PREVIEW_COLUMNS-3)) gh run view {-1} '"$REPO_FLAG" \
--prompt="run ❱ " \
--header="$run_header" \
--bind="start:${GH_FZF_HIDE_HINTS:+"toggle-header"}" \
Expand Down Expand Up @@ -495,7 +498,7 @@ $global_binds
FZF_DEFAULT_COMMAND="GH_FORCE_TTY=$GH_COLUMNS gh workflow list $workflow_template -L $GH_FZF_DEFAULT_LIMIT $*" \
fzf \
--prompt="workflow ❱ " \
--preview='GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh workflow view --yaml {-1} '"$REPO_FLAG" \
--preview='GH_FORCE_TTY=$((FZF_PREVIEW_COLUMNS-3)) gh workflow view --yaml {-1} '"$REPO_FLAG" \
--header="$workflow_header" \
--bind="start:${GH_FZF_HIDE_HINTS:+"toggle-header"}" \
--bind="ctrl-o:execute-silent(gh workflow view --web {-1} $REPO_FLAG &)+refresh-preview" \
Expand Down Expand Up @@ -559,7 +562,7 @@ $global_binds
# FZF COMMAND {{{2
FZF_DEFAULT_COMMAND="GH_FORCE_TTY=$GH_COLUMNS gh release list $release_template -L $GH_FZF_DEFAULT_LIMIT $*" \
fzf \
--preview='GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh release view {1} '"$REPO_FLAG" \
--preview='GH_FORCE_TTY=$((FZF_PREVIEW_COLUMNS-3)) gh release view {1} '"$REPO_FLAG" \
--prompt="release ❱ " \
--header="$release_header" \
--bind="start:${GH_FZF_HIDE_HINTS:+"toggle-header"}" \
Expand Down Expand Up @@ -769,7 +772,7 @@ $global_binds
# FZF COMMAND {{{2
FZF_DEFAULT_COMMAND="GH_FORCE_TTY=$GH_COLUMNS gh repo list -L $GH_FZF_DEFAULT_LIMIT $*" \
fzf \
--preview='GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh repo view {1}' \
--preview='GH_FORCE_TTY=$((FZF_PREVIEW_COLUMNS-3)) gh repo view {1}' \
--prompt="repo ❱ " \
--header="$repo_header" \
--header-lines=4 \
Expand Down Expand Up @@ -804,7 +807,7 @@ Filters > (alt-p: public) (alt-s: secret)
# FZF COMMAND {{{2
FZF_DEFAULT_COMMAND="GH_FORCE_TTY=$GH_COLUMNS gh gist list -L $GH_FZF_DEFAULT_LIMIT $*" \
fzf \
--preview='GH_FORCE_TTY=$FZF_PREVIEW_COLUMNS gh gist view {1}' \
--preview='GH_FORCE_TTY=$((FZF_PREVIEW_COLUMNS-3)) gh gist view {1}' \
--prompt="gist ❱ " \
--header="$gist_header" \
--bind="start:${GH_FZF_HIDE_HINTS:+"toggle-header"}" \
Expand Down

0 comments on commit 79cbd4b

Please sign in to comment.