summaryrefslogtreecommitdiff
path: root/Userland/Utilities
diff options
context:
space:
mode:
authorPeter Elliott <pelliott@ualberta.ca>2021-12-28 10:26:12 -0700
committerAndreas Kling <kling@serenityos.org>2021-12-29 00:00:02 +0100
commit23e09eb7f480ea383b1ccb40e6b6434291cc8840 (patch)
treee08aaa8d65e1afc8abb5f73579bd0e6bda5f297d /Userland/Utilities
parent20a0572de8e502380c676a3c2dca958aa12cd68a (diff)
downloadserenity-23e09eb7f480ea383b1ccb40e6b6434291cc8840.zip
less: Handle tabs in line wrapping
Before tabs were treated as a width of 1, which would cause issues with man page headers.
Diffstat (limited to 'Userland/Utilities')
-rw-r--r--Userland/Utilities/less.cpp12
1 files changed, 9 insertions, 3 deletions
diff --git a/Userland/Utilities/less.cpp b/Userland/Utilities/less.cpp
index 319712a59b..756befba63 100644
--- a/Userland/Utilities/less.cpp
+++ b/Userland/Utilities/less.cpp
@@ -75,9 +75,15 @@ static Vector<StringView> wrap_line(String const& string, size_t width)
if (*it == '\e')
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))
in_ansi = false;