AirGuanZ / imgui-filebrowser

File browser implementation for dear-imgui. C++17 is required.

Geek Repo:Geek Repo

Github PK Tool:Github PK Tool

Missing some extensions when using SetTypeFilters()

moso31 opened this issue · comments

When I try to use SetTypeFilters() like this

    fileDialog.SetTypeFilters({ ".*", ".dds" });

And make filter combobox to ",*". Then I'll get this
image

But I think it should be
image
(2 hdr file missed.)

So I switched location of these two code segments

    // all type filters
    if(typeFilters_.size() > 1 && typeFilterIndex_ == 0)
    {
        for(size_t i = 1; i < typeFilters_.size(); ++i)
        {
            if(extension == typeFilters_[i])
                return true;
        }
        return false;
    }

    // universal filter
    if(typeFilters_[typeFilterIndex_] == std::string_view(".*"))
        return true;

to

    // universal filter
    if(typeFilters_[typeFilterIndex_] == std::string_view(".*"))
        return true;

    // all type filters
    if(typeFilters_.size() > 1 && typeFilterIndex_ == 0)
    {
        for(size_t i = 1; i < typeFilters_.size(); ++i)
        {
            if(extension == typeFilters_[i])
                return true;
        }
        return false;
    }

And it will be fixed...
image

It's good for me. But I'm not sure will this cause any other problems...

Hi,

Thanks for telling me this!

This problem is actually caused by the if(typeFilters_.size() > 1 && typeFilterIndex_ == 0) condition. I used typeFilters_.size() > 1 to decide whether there is a 'all filter', which may cause incorrect result when there is a '.*'. I've upload a new version, which use a separate member variable to indicate the existence of 'all filter'.

Please try the new version. Hope that works well for you.

I've tried the new version and it worked great!