Pārlūkot izejas kodu

less: Handle tabs in line wrapping

Before tabs were treated as a width of 1, which would cause issues with
man page headers.
Peter Elliott 3 gadi atpakaļ
vecāks
revīzija
23e09eb7f4
1 mainītis faili ar 9 papildinājumiem un 3 dzēšanām
  1. 9 3
      Userland/Utilities/less.cpp

+ 9 - 3
Userland/Utilities/less.cpp

@@ -75,9 +75,15 @@ static Vector<StringView> wrap_line(String const& string, size_t width)
         if (*it == '\e')
         if (*it == '\e')
             in_ansi = true;
             in_ansi = true;
 
 
-        if (!in_ansi)
-            // FIXME: calculate the printed width of the character.
-            offset++;
+        if (!in_ansi) {
+            if (*it == '\t') {
+                // Tabs are a special case, because their width is variable.
+                offset += (8 - (offset % 8));
+            } else {
+                // FIXME: calculate the printed width of the character.
+                offset++;
+            }
+        }
 
 
         if (isalpha(*it))
         if (isalpha(*it))
             in_ansi = false;
             in_ansi = false;