Select project root when opening File System tree with project directory

When choosing "Show in File System View" from the context menu of a
project root node in Projects view, the File System view should show the
project root directly, not the project directory as a child in the
"Home" or "Computer" directories.

Change-Id: Id2d5794cf747fd6b52289f6d08ef14ef18cd2dd4
Reviewed-by: Cristian Adam <cristian.adam@qt.io>
This commit is contained in:
Eike Ziller
2021-09-29 09:50:29 +02:00
parent 258b4f7c23
commit 19ce3e91bb

View File

@@ -654,7 +654,8 @@ int FolderNavigationWidget::bestRootForFile(const Utils::FilePath &filePath)
int commonLength = 0;
for (int i = 1; i < m_rootSelector->count(); ++i) {
const auto root = m_rootSelector->itemData(i).value<Utils::FilePath>();
if (filePath.isChildOf(root) && root.toString().size() > commonLength) {
if ((filePath == root || filePath.isChildOf(root))
&& root.toString().size() > commonLength) {
index = i;
commonLength = root.toString().size();
}