From 3c73b6d531be3ef323a07df1a08794360bf87608 Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 28 Aug 2020 12:56:38 +0200 Subject: [PATCH] ls: Fix issue with too-narrow columns in "ls" output There was a logic mistake in the code that computes the offset between columns, forgetting to account for the extra characters after a name. The comment was accurate, but the code didn't match the comment. --- Userland/ls.cpp | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/Userland/ls.cpp b/Userland/ls.cpp index 7d97aa50e4..3054f7d895 100644 --- a/Userland/ls.cpp +++ b/Userland/ls.cpp @@ -421,7 +421,7 @@ int do_file_system_object_short(const char* path) // The offset must be at least 2 because: // - With each file an additional char is printed e.g. '@','*'. // - Each filename must be separated by a space. - size_t column_width = longest_name + (offset > 0 ? offset : 2); + size_t column_width = longest_name + max(offset, 2); printed_on_row += column_width; for (size_t j = nprinted; i != (names.size() - 1) && j < column_width; ++j)