243
}
244
245
>
function getAssociationByFirstline(firstLine: string): ILanguageAssociationItem | undefined {
languagesAssociations.ts
246
>
if (startsWithUTF8BOM(firstLine)) {
247
firstLine = firstLine.substring(1);
248
}
250
>
if (firstLine.length > 0) {
251
>
252
>
// We want to prioritize associations based on the order they are registered so that the last registered
253
>
// association wins over all other. This is for https://github.com/microsoft/vscode/issues/20074
254
>
for (let i = registeredAssociations.length - 1; i >= 0; i--) {
255
>
const association = registeredAssociations[i];
256
>
if (!association.firstline) {
257
continue;
258
}
260
>
const matches = firstLine.match(association.firstline);
261
>
if (matches && matches.length > 0) {
262
>
return association;
263
>
}
264
>
}
265
}
266