Is there a match function for vscode GlobPattern?

Viewed 27

For an extension I'm doing I want to match the uri.path of a newly opened file to a pair of include/exclude GlobPatterns.

I've found fileSearch() API that operates on GlobPatterns, but is overkill for this; I already have a file-path, just want to see if it satisfies the Globs.

Is there a simple "match" function for GlobPatterns?

1 Answers

Found it in: Is there a native api in vscode to match a document file by a glob?

[vscode.languages.match() dances through some alternatives, then invokes glob.match(...);]

import * as vscode from 'vscode';

documentMatchGlob(doc: vscode.TextDocument, glob: string): boolean {
    return vscode.languages.match({ pattern: glob }, document) !== 0;
}
Related