From de54a4c2ad4fbfa75a956766a7e89e925048903c Mon Sep 17 00:00:00 2001 From: noctuum <25441068+noctuum@users.noreply.github.com> Date: Wed, 16 Sep 2026 12:07:44 +0500 Subject: [PATCH] Clamp the negative width in wstring_width A narrow terminal makes the file list width go below zero. --- src/display/window_file_list.cc | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/display/window_file_list.cc b/src/display/window_file_list.cc index c15207c7..9a25beff 100644 --- a/src/display/window_file_list.cc +++ b/src/display/window_file_list.cc @@ -25,7 +25,10 @@ WindowFileList::WindowFileList(const ui::ElementFileList* element) : // Convert std::string to std::wstring of given width (in screen positions), // taking into account that some characters may be occupying two screen positions. std::wstring -wstring_width(const std::string& i_str, [[maybe_unused]] int width) { +wstring_width(const std::string& i_str, int width) { + if (width < 0) + width = 0; + std::wstring result(width + 1, L' '); size_t length = std::mbstowcs(result.data(), i_str.c_str(), width);