From f3c7c5b727ae010e299788ee55bae929dd5bb529 Mon Sep 17 00:00:00 2001 From: Max Kellermann Date: Thu, 12 Sep 2024 11:17:03 +0200 Subject: [PATCH] screen_utils: skip items which are at a deeper level Since the clear() call was removed, the given range may contain items which are at a deeper directory level, but we should only show those at the current level. --- src/screen_utils.cxx | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/src/screen_utils.cxx b/src/screen_utils.cxx index ce75142d..bde94584 100644 --- a/src/screen_utils.cxx +++ b/src/screen_utils.cxx @@ -44,7 +44,7 @@ screen_display_completion_list(ScreenManager &screen, SelectStyle(window, Style::STATUS_ALERT); auto i = std::next(range.begin(), offset); - for (unsigned y = 0; y < height; ++y, ++i) { + for (unsigned y = 0; y < height; ++i) { window.MoveCursor({0, (int)y}); if (i == range.end()) break; @@ -61,8 +61,15 @@ screen_display_completion_list(ScreenManager &screen, directory" */ s = "."sv; + if (const auto slash = s.find('/'); + slash != s.npos && slash + 1 < s.size()) + /* this item is from a deeper directory level: + skip it */ + continue; + window.String(s); window.ClearToEol(); + ++y; } window.ClearToBottom();