From 442a914d32bc2c86ff5d6a5e54a1b33f99f7f8b6 Mon Sep 17 00:00:00 2001 From: Andrea Bergonzo Date: Wed, 18 Mar 2026 05:07:15 +0000 Subject: [PATCH] fix: Health Deficit + Abbreviate (K/M) not working outside Test Mode The C_StringUtil code path always took priority over the abbreviation logic. Since C_StringUtil APIs are always available, the db.healthTextAbbreviate + AbbreviateNumbers branch was never reached. Fix: set the text via TruncateWhenZero + WrapString first (which correctly hides zero deficit even with secret/tainted values), then check GetText() truthiness to conditionally overwrite with the abbreviated form. This avoids comparing tainted values (which errors in instanced content) while preserving both abbreviation and zero hiding. --- Frames/Update.lua | 33 +++++++++++++++++++-------------- 1 file changed, 19 insertions(+), 14 deletions(-) diff --git a/Frames/Update.lua b/Frames/Update.lua index 889ebb9..83dd5ed 100644 --- a/Frames/Update.lua +++ b/Frames/Update.lua @@ -799,9 +799,10 @@ function DF:UpdateUnitFrame(frame, source) local deficit = UnitHealthMissing(unit, true) if deficit then if C_StringUtil and C_StringUtil.TruncateWhenZero and C_StringUtil.WrapString then - local truncated = C_StringUtil.TruncateWhenZero(deficit) - local result = C_StringUtil.WrapString(truncated, "-") - frame.healthText:SetText(result) + frame.healthText:SetText(C_StringUtil.WrapString(C_StringUtil.TruncateWhenZero(deficit), "-")) + if db.healthTextAbbreviate and AbbreviateNumbers and frame.healthText:GetText() then + frame.healthText:SetFormattedText("-%s", AbbreviateNumbers(deficit)) + end elseif db.healthTextAbbreviate and AbbreviateNumbers then frame.healthText:SetFormattedText("-%s", AbbreviateNumbers(deficit)) else @@ -1057,9 +1058,10 @@ function DF:UpdateHealthFast(frame) local deficit = UnitHealthMissing(unit, true) if deficit then if C_StringUtil and C_StringUtil.TruncateWhenZero and C_StringUtil.WrapString then - local truncated = C_StringUtil.TruncateWhenZero(deficit) - local result = C_StringUtil.WrapString(truncated, "-") - frame.healthText:SetText(result) + frame.healthText:SetText(C_StringUtil.WrapString(C_StringUtil.TruncateWhenZero(deficit), "-")) + if db.healthTextAbbreviate and AbbreviateNumbers and frame.healthText:GetText() then + frame.healthText:SetFormattedText("-%s", AbbreviateNumbers(deficit)) + end elseif db.healthTextAbbreviate and AbbreviateNumbers then frame.healthText:SetFormattedText("-%s", AbbreviateNumbers(deficit)) else @@ -1270,14 +1272,17 @@ function DF:UpdateHealth(frame) elseif format == "DEFICIT" then local miss = UnitHealthMissing(unit, true) - if C_StringUtil and C_StringUtil.TruncateWhenZero and C_StringUtil.WrapString then - local truncated = C_StringUtil.TruncateWhenZero(miss) - local result = C_StringUtil.WrapString(truncated, "-") - frame.healthText:SetText(result) - elseif db.healthTextAbbreviate then - frame.healthText:SetFormattedText("-%s", FormatValue(miss)) - else - frame.healthText:SetFormattedText("-%s", miss) + if miss then + if C_StringUtil and C_StringUtil.TruncateWhenZero and C_StringUtil.WrapString then + frame.healthText:SetText(C_StringUtil.WrapString(C_StringUtil.TruncateWhenZero(miss), "-")) + if db.healthTextAbbreviate and frame.healthText:GetText() then + frame.healthText:SetFormattedText("-%s", FormatValue(miss)) + end + elseif db.healthTextAbbreviate then + frame.healthText:SetFormattedText("-%s", FormatValue(miss)) + else + frame.healthText:SetFormattedText("-%s", miss) + end end elseif format == "CURRENT" then local curr = UnitHealth(unit, true)