Skip to content

Commit

Permalink
choose-*: improve multiline indentation and sizing
Browse files Browse the repository at this point in the history
  • Loading branch information
balupton committed Nov 3, 2023
1 parent 0e285df commit 78bc649
Showing 1 changed file with 3 additions and 2 deletions.
5 changes: 3 additions & 2 deletions commands/choose-menu
Original file line number Diff line number Diff line change
Expand Up @@ -522,7 +522,7 @@ function choose_menu() (
item_size="${sizes[index]}"
else
item_original="${items[index]}"
if test "${#item_original}" -lt "$size_content" && [[ $item_original != $'\n' && $item_original != $'\t' ]]; then
if test "${#item_original}" -lt "$size_content" && [[ $item_original != *$'\n'* && $item_original != *$'\t'* ]]; then
# no need to format item, as it is small enough
item_rendered="$item_original"
item_size=1
Expand All @@ -531,7 +531,8 @@ function choose_menu() (
else
# need to format item, as it is too big
item_rendered="$("$bin_gfmt" -t -w "$size_content" <<<"$item_original")"
item_size="$("$bin_gwc" -l <<<"${item_original}"$'\n')"
item_rendered="${item_rendered//$'\n'/$'\n '}"
item_size="$("$bin_gwc" -l <<<"${item_rendered}")"
renders[index]="$item_rendered"
sizes[index]="$item_size"
fi
Expand Down

0 comments on commit 78bc649

Please sign in to comment.