From 9fb538d1253d7244012cc2d6be3602b48b58f0e6 Mon Sep 17 00:00:00 2001 From: PeterCJ Date: Sat, 27 Jul 2024 14:04:18 -0700 Subject: [PATCH] Add file type filters for UDL in Save dialogs Fix #8083, fix #11096, close #15490 --- PowerEditor/src/NppIO.cpp | 40 +++++++++++++++++++++++++++++++++++++++ 1 file changed, 40 insertions(+) diff --git a/PowerEditor/src/NppIO.cpp b/PowerEditor/src/NppIO.cpp index ac4d18af1..221df5e20 100644 --- a/PowerEditor/src/NppIO.cpp +++ b/PowerEditor/src/NppIO.cpp @@ -993,6 +993,46 @@ int Notepad_plus::setFileOpenSaveDlgFilters(CustomFileDialog & fDlg, bool showAl } l = (NppParameters::getInstance()).getLangFromIndex(i++); } + + LangType lt = (LangType)langType; + wstring fileUdlString(getLangDesc(lt, true)); + + for (size_t u=0; u<(size_t)nppParam.getNbUserLang(); u++) + { + UserLangContainer& ulc = nppParam.getULCFromIndex(u); + const wchar_t *extList = ulc.getExtention(); + const wchar_t *lName = ulc.getName(); + + wstring list(L""); + if (extList) + list += extList; + + wstring stringFilters = exts2Filters(list, showAllExt ? -1 : 40); + const wchar_t *filters = stringFilters.c_str(); + + if (filters[0]) + { + fDlg.setExtFilter(lName, filters); + + if (lt == L_USER) + { + wstring loopUdlString(L"udf - "); + loopUdlString += lName; + + if (!ltFound) + { + ltFound = fileUdlString.compare(loopUdlString) == 0; + } + + if (!ltFound) + { + ++ltIndex; + } + } + } + } + + if (!ltFound) return -1;