@@ -35,13 +35,32 @@ CustomSubExplorerCommand::CustomSubExplorerCommand(const winrt::hstring& configC
3535 _show_window_flag = static_cast <int >(result.GetNamedNumber (L" showWindowFlag" , 0 ));
3636 _working_directory = result.GetNamedString (L" workingDirectory" , L" " );
3737
38- //
38+ // TODO remove next version
3939 if (_accept_file_flag == 0 && _accept_file) {
4040 _accept_file_flag = FILE_EXT;
4141 }
42+ // TODO remove next version
4243 if (_accept_directory_flag == 0 && _accept_directory) {
4344 _accept_directory_flag = DIRECTORY_DIRECTORY | DIRECTORY_BACKGROUND | DIRECTORY_DESKTOP;
4445 }
46+
47+ if (_accept_file_flag == FileMatchFlagEnum::FILE_EXT2 && !_accept_exts.empty ()) {
48+ std::wstring_view acceptExtsView{ _accept_exts };
49+
50+ for (std::size_t start = 0 ; start <= acceptExtsView.size ();)
51+ {
52+ const auto pos = acceptExtsView.find (L' |' , start);
53+ const auto last = pos == std::wstring_view::npos;
54+ std::wstring_view token = last ? acceptExtsView.substr (start) : acceptExtsView.substr (start, pos - start);
55+ if (!token.empty ()) {
56+ _accept_exts_set.emplace (token);
57+ }
58+ if (last) {
59+ break ;
60+ }
61+ start = pos + 1 ;
62+ }
63+ }
4564 }
4665 catch (winrt::hresult_error const & e)
4766 {
@@ -80,18 +99,7 @@ bool CustomSubExplorerCommand::Accept(bool multipleFiles, FileType fileType, con
8099 return false ;
81100 }
82101
83- const size_t position = _accept_exts.find (ext);
84- if (position != std::string::npos) {
85- // check for .c .cpp
86- const bool isStart = position == 0 ;
87- const bool isEnd = position + ext.size () == _accept_exts.size ();
88- const bool isPrevComma = !isStart && _accept_exts[position - 1 ] == L' |' ;
89- const bool isNextComma = !isEnd && _accept_exts[position + ext.size ()] == L' |' ;
90- if ((isStart || isPrevComma) && (isEnd || isNextComma)) {
91- return true ;
92- }
93- }
94- return false ;
102+ return _accept_exts_set.contains (ext);
95103 }
96104 else if (_accept_file_flag == FileMatchFlagEnum::FILE_REGEX) {
97105 DEBUG_LOG (L" CustomSubExplorerCommand::Accept menu={}, file=regex, ext={}" , _title, _accept_file_regex);
0 commit comments