mirror of
https://github.com/Microsoft/vscode
synced 2024-08-27 13:00:58 +00:00
Add validation for empty pattern in custom editor labels (#208809)
Add validation for custom editor label patterns fixes #208723
This commit is contained in:
parent
0c5078aacd
commit
9d8c22a86c
|
@ -109,6 +109,8 @@ const registry = Registry.as<IConfigurationRegistry>(ConfigurationExtensions.Con
|
|||
{
|
||||
type: 'string',
|
||||
markdownDescription: localize('workbench.editor.label.template', "The template which should be rendered when the pattern mtches. May include the variables ${dirname}, ${filename} and ${extname}."),
|
||||
minLength: 1,
|
||||
pattern: '.*[a-zA-Z0-9].*'
|
||||
},
|
||||
'default': {}
|
||||
},
|
||||
|
|
|
@ -74,12 +74,17 @@ export class CustomEditorLabelService extends Disposable implements ICustomEdito
|
|||
this.enabled = this.configurationService.getValue<boolean>(CustomEditorLabelService.SETTING_ID_ENABLED);
|
||||
}
|
||||
|
||||
private _templateRegexValidation: RegExp = /[a-zA-Z0-9]/;
|
||||
private storeCustomPatterns(): void {
|
||||
this.patterns = [];
|
||||
const customLabelPatterns = this.configurationService.getValue<ICustomEditorLabelObject>(CustomEditorLabelService.SETTING_ID_PATTERNS);
|
||||
for (const pattern in customLabelPatterns) {
|
||||
const template = customLabelPatterns[pattern];
|
||||
|
||||
if (!this._templateRegexValidation.test(template)) {
|
||||
continue;
|
||||
}
|
||||
|
||||
const isAbsolutePath = isAbsolute(pattern);
|
||||
const parsedPattern = parseGlob(pattern);
|
||||
|
||||
|
|
Loading…
Reference in a new issue