Skip to content

Commit

Permalink
choose: disable truncate body functionality unless --truncate-body
Browse files Browse the repository at this point in the history
…is enabled
  • Loading branch information
balupton committed Jan 22, 2025
1 parent a294247 commit f359926
Showing 1 changed file with 3 additions and 4 deletions.
7 changes: 3 additions & 4 deletions commands/choose
Original file line number Diff line number Diff line change
Expand Up @@ -673,7 +673,7 @@ function choose_() (
Whether the prompt should persist afterwards.
--[no-]truncate-body=[yes|NO]
Truncate the body if it is too long and would prevent the menu from being entirely viewable without a font size change.
Truncate the body if it would prevent the menu items from being visible.
--timeout=<timeout>
Custom timeout value in seconds.
Expand Down Expand Up @@ -1173,7 +1173,6 @@ function choose_() (
if [[ -n $question_title ]]; then
menu_title="${style__question_title_prompt}${question_title}${style__end__question_title_prompt}"$'\n'
fi
# trunk-ignore(shellcheck/SC2120)
function render_body {
local limit="${1-}" trimmed_lines=0
if [[ -n $question_body ]]; then
Expand All @@ -1182,7 +1181,7 @@ function choose_() (
menu_body_rows_whole="$(echo-wrap --width="$content_columns" -- "$menu_body" | echo-count-lines --stdin)"
fi
menu_body_rows="$menu_body_rows_whole"
if [[ -z $limit || $menu_body_rows -le $limit ]]; then
if [[ $option_truncate_body != 'yes' || -z $limit || $menu_body_rows -le $limit ]]; then
return
fi
while :; do
Expand Down Expand Up @@ -1869,7 +1868,7 @@ function choose_() (
fi

# adjust the menu body
if [[ $paging_supported == 'yes' && -n $question_body ]]; then
if [[ $option_truncate_body = 'yes' && $paging_supported == 'yes' && -n $question_body ]]; then
if [[ $menu_rows -lt $terminal_lines ]]; then
# there were less menu rows than terminal lines, so lets see if we can expand the body
if [[ $menu_body_rows_whole -gt $menu_body_rows ]]; then
Expand Down

0 comments on commit f359926

Please sign in to comment.