How do I filter problems by multiple criteria? AND or OR

1.7k Views Asked by At

In the problems pane you can filter/exclude by text or file, but what if I want to filter by multiple criteria? Like filter messages for those that contain the text X OR Y (or X AND Y). I know you can filter for multiple types of files by using commas, is there a similar mechanism for text?

2

There are 2 best solutions below

1
Mark On

An extension I wrote, Problems: Copy allows you to filter text using a regex. So you could do something like this:

{
  "key": "alt+c",                      // whatever keybinding you want, no default
  "command": "problems-copy.copyAll",
  "args": {
    "errors": true,                   // will be included in the result
    "warnings": true,
    // "hints": true,          // any category not in the keybinding will NOT be in the result
    "informations": true,
    
    "messageFilter": "/const2|typeof/",   // wrapped in regex literals
  }
}

So that will copy problems with the word const2 or typeof. With the appropriate regex you should be able to construct the filter you want.


This extension cannot actually filter the problems that appear in the Problems Panel - that functionality is not available in the extension api. With the extension you can copy/paste the filtered problems to another editor though (or spreadsheet, etc.).

0
Leo On

As far as I can see, this is still not possible to do generically as of Oct 2022. This issue discusses the problem and links to more specific issues.

However, the , seems to be an OR operator. The filter below works for me for Python development. I want issues to be ignored for interactive (notebook) sessions as well as for a scratch.py file that I use to sketch out ideas before putting them in assets:

!scratch.py,!Interactive*

The PROBLEMS tab still shows the total count of "problems" (see 21 in the example below), but none of those problems are in files that I care about.enter image description here