From 76ae47c6ed0594329b67c7d45892b474be82b97e Mon Sep 17 00:00:00 2001 From: Andreas Kling Date: Fri, 18 Sep 2020 18:32:35 +0200 Subject: [PATCH] LibGUI: Unbreak FileSystemModel::index(path) after virtual root changes Now that the "/" directory can have a (virtual) parent index, we need to account for that when converting a full path to a model index. --- Libraries/LibGUI/FileSystemModel.cpp | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/Libraries/LibGUI/FileSystemModel.cpp b/Libraries/LibGUI/FileSystemModel.cpp index 33bb32923a..10df60a4ef 100644 --- a/Libraries/LibGUI/FileSystemModel.cpp +++ b/Libraries/LibGUI/FileSystemModel.cpp @@ -187,9 +187,9 @@ String FileSystemModel::Node::full_path() const ModelIndex FileSystemModel::index(const StringView& path, int column) const { LexicalPath lexical_path(path); - const Node* node = m_root; + const Node* node = m_root->m_parent_of_root ? &m_root->children.first() : m_root; if (lexical_path.string() == "/") - return m_root->index(column); + return node->index(column); for (size_t i = 0; i < lexical_path.parts().size(); ++i) { auto& part = lexical_path.parts()[i]; bool found = false;