Handle custom editor filenamePattern for paths

Fixes #94383
This commit is contained in:
Matt Bierner 2020-04-03 10:21:10 -07:00
parent cf6c74f026
commit 05f97f5dbf

View file

@ -7,6 +7,7 @@ import { distinct, mergeSort } from 'vs/base/common/arrays';
import { Event } from 'vs/base/common/event';
import * as glob from 'vs/base/common/glob';
import { IDisposable, IReference } from 'vs/base/common/lifecycle';
import { posix } from 'vs/base/common/path';
import { basename } from 'vs/base/common/resources';
import { URI } from 'vs/base/common/uri';
import { RawContextKey } from 'vs/platform/contextkey/common/contextkey';
@ -96,7 +97,9 @@ export class CustomEditorInfo {
static selectorMatches(selector: CustomEditorSelector, resource: URI): boolean {
if (selector.filenamePattern) {
if (glob.match(selector.filenamePattern.toLowerCase(), basename(resource).toLowerCase())) {
const matchOnPath = selector.filenamePattern.indexOf(posix.sep) >= 0;
const target = matchOnPath ? resource.path : basename(resource);
if (glob.match(selector.filenamePattern.toLowerCase(), target.toLowerCase())) {
return true;
}
}