From 6e1a7a15cd824d8ba1846fa8f009e55e6d21bec3 Mon Sep 17 00:00:00 2001 From: x-ist Date: Mon, 6 Aug 2012 19:44:42 +0000 Subject: [PATCH] Fix BTextView tab calculation. In rare cases such as described in #7955 BTextView happens to calculate the width of a tab close to zero (e.g. 0.000031). This patch adds a fallback to the default tab width in that case. Signed-off-by: Ryan Leavengood --- src/kits/interface/TextView.cpp | 6 +++++- 1 file changed, 5 insertions(+), 1 deletion(-) diff --git a/src/kits/interface/TextView.cpp b/src/kits/interface/TextView.cpp index d46414d982..f93582850f 100644 --- a/src/kits/interface/TextView.cpp +++ b/src/kits/interface/TextView.cpp @@ -4198,7 +4198,11 @@ BTextView::_StyledWidth(int32 fromOffset, int32 length, float* outAscent, float BTextView::_ActualTabWidth(float location) const { - return fTabWidth - fmod(location, fTabWidth); + float tabWidth = fTabWidth - fmod(location, fTabWidth); + if (round(tabWidth) == 0) + tabWidth = fTabWidth; + + return tabWidth; }