Skip to content

Commit 6cc430a

Browse files
committed
[FIX] fix issue with GetSelection() when directory opened and no files/dirs selection
1 parent 4b82b54 commit 6cc430a

1 file changed

Lines changed: 16 additions & 7 deletions

File tree

ImGuiFileDialog.cpp

Lines changed: 16 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1975,11 +1975,13 @@ bool IGFD::FileManager::m_CompleteFileInfosWithUserFileAttirbutes(const FileDial
19751975
void IGFD::FileManager::ClearFileLists() {
19761976
m_FilteredFileList.clear();
19771977
m_FileList.clear();
1978+
m_SelectedFileNames.clear();
19781979
}
19791980

19801981
void IGFD::FileManager::ClearPathLists() {
19811982
m_FilteredPathList.clear();
19821983
m_PathList.clear();
1984+
m_SelectedFileNames.clear();
19831985
}
19841986

19851987
void IGFD::FileManager::m_AddFile(const FileDialogInternal& vFileDialogInternal, const std::string& vPath, const std::string& vFileName, const FileType& vFileType) {
@@ -2711,16 +2713,23 @@ std::string IGFD::FileManager::GetResultingFilePathName(FileDialogInternal& vFil
27112713

27122714
std::map<std::string, std::string> IGFD::FileManager::GetResultingSelection(FileDialogInternal& vFileDialogInternal, IGFD_ResultMode vFlag) {
27132715
std::map<std::string, std::string> res;
2714-
for (const auto& selectedFileName : m_SelectedFileNames) {
2715-
auto result = GetResultingPath();
2716+
const auto& result_path = GetResultingPath();
2717+
if (!m_SelectedFileNames.empty()) {
2718+
for (const auto& selectedFileName : m_SelectedFileNames) {
2719+
auto result = result_path;
27162720
#ifdef _IGFD_UNIX_
2717-
if (fsRoot != result)
2721+
if (fsRoot != result)
27182722
#endif // _IGFD_UNIX_
2719-
{
2720-
result += IGFD::Utils::GetPathSeparator();
2723+
{
2724+
result += IGFD::Utils::GetPathSeparator();
2725+
}
2726+
result += vFileDialogInternal.filterManager.ReplaceExtentionWithCurrentFilterIfNeeded(selectedFileName, vFlag);
2727+
res[selectedFileName] = result;
2728+
}
2729+
} else { // opened directory with no selection
2730+
if (vFileDialogInternal.fileManager.dLGDirectoryMode) { // directory mode
2731+
res["."] = result_path;
27212732
}
2722-
result += vFileDialogInternal.filterManager.ReplaceExtentionWithCurrentFilterIfNeeded(selectedFileName, vFlag);
2723-
res[selectedFileName] = result;
27242733
}
27252734
return res;
27262735
}

0 commit comments

Comments
 (0)