From 85c926f2715b4a6e8c0224c21c0138479ca9fe9e Mon Sep 17 00:00:00 2001 From: AngryFender Date: Fri, 8 Mar 2024 00:25:13 +0000 Subject: [PATCH] Github Issue #140: Fixed a bug where new files/folder could be created at the root level of the vault. --- navigationview.cpp | 18 ++++++++++-------- 1 file changed, 10 insertions(+), 8 deletions(-) diff --git a/navigationview.cpp b/navigationview.cpp index 94df0d5..6fe5b92 100644 --- a/navigationview.cpp +++ b/navigationview.cpp @@ -133,12 +133,13 @@ void NavigationView::addFile() this->scrollTo(index); const QList selections = this->selectedIndexes(); - QModelIndex current = selections.first(); + if(!selections.empty() && lastClickedIndex.isValid()){ + index = selections.first(); + } QString fileName; - emit createFile(current, fileName); - - lastClickedIndex = current; + emit createFile(index, fileName); + lastClickedIndex = index; newEntryName = fileName; } @@ -151,12 +152,13 @@ void NavigationView::addFolder() this->scrollTo(index); const QList selections = this->selectedIndexes(); - QModelIndex current = selections.first(); + if(!selections.isEmpty() && lastClickedIndex.isValid()){ + index = selections.first(); + } QString folderName; - emit createFolder(current, folderName); - - lastClickedIndex = current; + emit createFolder(index, folderName); + lastClickedIndex = index; newEntryName = folderName; }