mirror of
https://github.com/Microsoft/vscode
synced 2024-09-18 01:58:27 +00:00
Relax Language First Line Match (#21586)
* Relax Language First Line Match Fixes #21533 **Bug** The first line pattern for a language currently requires the entire line to match. This does is different from how tools such as textmate use firstLineMatch **Fix** Relax this restriction so that any match is used * Fix failing test
This commit is contained in:
parent
9b91a22918
commit
6b74e23c53
|
@ -202,9 +202,8 @@ function guessMimeTypeByFirstline(firstLine: string): string {
|
|||
continue;
|
||||
}
|
||||
|
||||
// Make sure the entire line matches, not just a subpart.
|
||||
let matches = firstLine.match(association.firstline);
|
||||
if (matches && matches.length > 0 && matches[0].length === firstLine.length) {
|
||||
if (matches && matches.length > 0) {
|
||||
return association.mime;
|
||||
}
|
||||
}
|
||||
|
|
|
@ -37,7 +37,7 @@ suite('Mime', () => {
|
|||
guess = guessMimeTypes('Randomfile.noregistration', 'RegexesAreNice');
|
||||
assert.deepEqual(guess, ['text/nice-regex', 'text/plain']);
|
||||
|
||||
guess = guessMimeTypes('Randomfile.noregistration', 'RegexesAreNiceee');
|
||||
guess = guessMimeTypes('Randomfile.noregistration', 'RegexesAreNotNice');
|
||||
assert.deepEqual(guess, ['application/unknown']);
|
||||
|
||||
guess = guessMimeTypes('Codefile', 'RegexesAreNice');
|
||||
|
|
Loading…
Reference in a new issue