danipen / TextMateSharp

A port of tm4e to bring TextMate grammars to dotnet ecosystem
MIT License
87 stars 15 forks source link

RegistryOptions.GetScopeByExtension causes NullReferenceException #33

Closed Excalidrill closed 1 year ago

Excalidrill commented 1 year ago

if language doesn't have extensions, NullReferenceException is thrown. Solution: add

if (language.Extensions == null)
    continue;

before foreach loop, as by RegistryOptions.GetLanguageByExtension

danipen commented 1 year ago

The null check is already there: https://github.com/danipen/TextMateSharp/blob/7845809e3e69162a3a6a1ee001d953f1dead3745/src/TextMateSharp.Grammars/RegistryOptions.cs#L55

Excalidrill commented 1 year ago

Yes, It is in GetLanguageByExtension, but not in GetScopeByExtension https://github.com/danipen/TextMateSharp/blob/7845809e3e69162a3a6a1ee001d953f1dead3745/src/TextMateSharp.Grammars/RegistryOptions.cs#L77

danipen commented 1 year ago

Fixed in https://github.com/danipen/TextMateSharp/commit/1a816bb5ed9864aa88c252848dabafeea6b5a9ae

danipen commented 1 year ago

A new package TextMateSharp 1.0.44 was recently published on NuGet Gallery with this fix.