1
0
mirror of https://github.com/tw93/Mole.git synced 2026-02-04 15:04:42 +00:00

fix: use \033[2K to fully clear spinner lines and prevent text remnants

Fixes text remnants showing when spinner messages change from longer to shorter text. Changed from \033[K (clear to end of line) to \033[2K (clear entire line) in stop_section_spinner(), safe_clear_line(), and safe_clear_lines() functions.

Fixes #390
This commit is contained in:
tw93
2026-01-30 18:16:31 +08:00
parent e81be16031
commit 1e650d8144

View File

@@ -628,7 +628,7 @@ start_section_spinner() {
stop_section_spinner() { stop_section_spinner() {
stop_inline_spinner 2> /dev/null || true stop_inline_spinner 2> /dev/null || true
if [[ -t 1 ]]; then if [[ -t 1 ]]; then
echo -ne "\r\033[K" >&2 || true echo -ne "\r\033[2K" >&2 || true
fi fi
} }
@@ -646,7 +646,7 @@ safe_clear_lines() {
# Clear lines one by one (more reliable than multi-line sequences) # Clear lines one by one (more reliable than multi-line sequences)
local i local i
for ((i = 0; i < lines; i++)); do for ((i = 0; i < lines; i++)); do
printf "\033[1A\r\033[K" > "$tty_device" 2> /dev/null || return 1 printf "\033[1A\r\033[2K" > "$tty_device" 2> /dev/null || return 1
done done
return 0 return 0
@@ -660,7 +660,7 @@ safe_clear_line() {
# Use centralized ANSI support check # Use centralized ANSI support check
is_ansi_supported 2> /dev/null || return 1 is_ansi_supported 2> /dev/null || return 1
printf "\r\033[K" > "$tty_device" 2> /dev/null || return 1 printf "\r\033[2K" > "$tty_device" 2> /dev/null || return 1
return 0 return 0
} }