Author Topic: Find in files: Conflicting filters  (Read 60 times)

jporkkahtc

  • Senior Community Member
  • Posts: 2288
  • Hero Points: 197
  • Text
Find in files: Conflicting filters
« on: September 13, 2021, 11:55:44 pm »
In FindInFiles a warning would be nice if the "FileTypes" and "Exclude Files" contain duplicate filters.

This test should be after <Default Excludes> or <Binary Files> is expanded.
This doesn't need to be really complex.

It could just compare FileTypes to Excludes and warn for any duplicates.
A little better might be:
    Create 2 lists:
        Includes: For each filter in "FileType", simplify it:
            if the extension is not wild, then add "*.<ext>"
            if the filename is not wild, then add "<name>.*"
            if both are not wild, then add 3: "*.<ext>", "<name>.*", "<name>.<ext>"

        Excludes: For each exclusion: Select filters of the form "*.<ext>", "<name>.*", and filters without wildcards (e.g "myFile.txt"). Ignore everything else.

    Then compare the two lists -- any matches are a warning.
The warning can appear in the search results, at the top.

Examples where it would warn:
Code: [Select]
FileType: *.pdf
Exclude: <Binary Files>;*.cs

FileType: *.cs
Exclude: <Binary Files>;*.cs

FileType: *SpecialCase*.cs
Exclude: <Binary Files>;*.cs

Examples where it would not warn:
Code: [Select]
FileType: *SpecialCase*cs
Exclude: <Binary Files>;*.cs

[code]FileType: *.cs
Exclude: <Binary Files>;Exceptional*.cs