fix(config-settings): sponge bools use true/false; hint width; set -- hardening

- C1: sponge_purge_only_on_exit / sponge_allow_previously_successful are 'bool'
  rows that write true/false (sponge's convention), not on/off; badge maps
  true->ON, false->OFF, unset->DEFAULT
- I1: shorten value-page hint to 49 cols so it fits the 50-wide tier
- M1: set -U -- before the var name guards typed values beginning with a dash
This commit is contained in:
2026-06-24 00:49:23 -04:00
parent 5cf5ca07c5
commit 453b5f1d50
3 changed files with 28 additions and 21 deletions
+7 -6
View File
@@ -48,7 +48,7 @@ function __config_settings_draw_value
set active_idx 2
set vars sponge_delay sponge_purge_only_on_exit sponge_allow_previously_successful sponge_successful_exit_codes __fish_sponge_extra_sensitive
set labels Delay "Purge@exit" "Allow prev" "OK codes" "Extra secret"
set types int toggle toggle list list
set types int bool bool list list
set hints 2 false true 0 "(none)"
else
set title "Path Settings"
@@ -94,12 +94,13 @@ function __config_settings_draw_value
# Badge (7 visible cols) + value field
set -l badge
set -l field
if test $type = toggle
set -l val (__config_settings_get_val $var universal)
if test $type = bool
# Booleans store true/false (sponge convention); unset = DEFAULT.
set -l val (__config_settings_get_raw $var)
switch $val
case on
case true
set badge "$c_ok"" ON$c_reset"
case off
case false
set badge "$c_err""OFF $c_reset"
case '*'
set badge "$c_dim""DEFAULT$c_reset"
@@ -145,7 +146,7 @@ function __config_settings_draw_value
printf '%s│%s│\n' $p $HBR
# ── Hint line ─────────────────────────────────────────────────────────
set -l hint_line " ↑↓/kj move Enter edit ←/h clear Tab page q quit"
set -l hint_line " ↑↓ move Enter edit ←/h clear Tab page q quit"
printf '%s│%s%s%s│\n' $p $c_dim (string pad -r -w $iw -- $hint_line) $c_reset
# ── Bottom border ─────────────────────────────────────────────────────
+3 -3
View File
@@ -38,10 +38,10 @@ function __config_settings_set_value
else
switch $type
case list
set -U $varname (string split -n ' ' -- $value) 2>/dev/null
set -U -- $varname (string split -n ' ' -- $value) 2>/dev/null
case '*'
# ponytail: values here are paths/ints/tokens, never leading-dash
set -U $varname $value 2>/dev/null
# -- (before the name) guards typed input that begins with a dash
set -U -- $varname $value 2>/dev/null
end
end
+18 -12
View File
@@ -78,7 +78,7 @@ function config-settings --description 'Interactive TUI for managing fish config
# ── Value-page row metadata (parallel: var / type) ────────────────────
set -l sponge_vars sponge_delay sponge_purge_only_on_exit sponge_allow_previously_successful sponge_successful_exit_codes __fish_sponge_extra_sensitive
set -l sponge_types int toggle toggle list list
set -l sponge_types int bool bool list list
set -l sponge_labels Delay "Purge@exit" "Allow prev" "OK codes" "Extra secret"
set -l paths_vars __fish_scrollback_history_dir __fish_scrollback_history_max_files __fish_user_dots_path
set -l paths_types path int path
@@ -154,14 +154,17 @@ function config-settings --description 'Interactive TUI for managing fish config
test "$cur_val" = off; and set next_val DEFAULT
__config_settings_apply $varname $scope $next_val
else if test $cur_page -eq 2
# Sponge page: only toggle-type rows respond to →
# Sponge page: only bool rows respond to → (false ← DEFAULT → true).
# Sponge reads true/false (not on/off), so write those literals.
set -l ridx (math $cur_row + 1)
if test "$sponge_types[$ridx]" = toggle
if test "$sponge_types[$ridx]" = bool
set -l varname $sponge_vars[$ridx]
set -l cur_val (__config_settings_get_val $varname universal)
set -l next_val on
test "$cur_val" = off; and set next_val DEFAULT
__config_settings_apply $varname universal $next_val
set -l cur_val (__config_settings_get_raw $varname)
if test "$cur_val" = false
set -Ue $varname 2>/dev/null
else
set -U $varname true 2>/dev/null
end
end
end
case left h
@@ -183,11 +186,14 @@ function config-settings --description 'Interactive TUI for managing fish config
end
set -l varname $v_vars[(math $cur_row + 1)]
set -l vtype $v_types[(math $cur_row + 1)]
if test "$vtype" = toggle
set -l cur_val (__config_settings_get_val $varname universal)
set -l next_val off
test "$cur_val" = on; and set next_val DEFAULT
__config_settings_apply $varname universal $next_val
if test "$vtype" = bool
# Step toward OFF (true → DEFAULT → false); sponge reads true/false.
set -l cur_val (__config_settings_get_raw $varname)
if test "$cur_val" = true
set -Ue $varname 2>/dev/null
else
set -U $varname false 2>/dev/null
end
else
__config_settings_set_value $varname $vtype ''
end