Please note: this is a minor issue, and I'm just reporting it to raise awareness and to include repro code so it may be tracked in the future.
The monaco_languages.json file includes a mapping of file extensions to language IDs. This allows for syntax highlighting on a per-language basis.
There exist 3 cases where the same file extension is present for multiple languages. This may result in incorrect syntax highlighting in one of those cases.
The code to repro the issue is as follows:
using System.Text.Json;
string json = File.ReadAllText("monaco_languages.json");
using var jsonDoc = JsonDocument.Parse(json);
var list = jsonDoc.RootElement.GetProperty("list");
foreach (var entry in list.EnumerateArray()
.Where(item => item.TryGetProperty("id", out var _) && item.TryGetProperty("extensions", out var _))
.SelectMany(item => item.GetProperty("extensions").EnumerateArray()
.Select(ext => new
{
Extension = ext.GetString(),
Id = item.GetProperty("id").GetString()
})
).GroupBy(pair => pair.Extension)
.Where(group => group.Count() > 1)
.Select(group => new
{
Extension = group.Key,
Ids = group.Select(x => x.Id)
}))
{
Console.WriteLine($"Extension '{entry.Extension}' used by IDs {string.Join(", ", entry.Ids)}");
}
(Setup a new Console application with this code as Program.cs and also copy in the current monaco_languages.json file, setting that file to be copied to the output directory.)
The results are:
Extension '.gitconfig' used by IDs ini, iniExt
Extension '.pp' used by IDs pascal, ruby
Extension '.csproj' used by IDs xml, xmlExt
The lookup for Monaco language matching in PowerToys will always pick the first match, so a file with a .pp extension will always be recognised as Pascal, even if it is a Puppet manifest file. (I assume the other 2 cases are OK, as the language IDs appear synonymous.)
I'm unsure what the resolution for this is without doing file introspection. That's probably unreasonable, especially for a single case such as this.
If it was decided to favour Puppet files over Pascal, the entry for Ruby should be moved before Pascal's in the file.
✔️ Expected Behavior
Files for Pascal and Puppet manifest files should be recognised as distinct, and highlighted differently by Monaco.
❌ Actual Behavior
As the files share the same extension, they cannot be distinguished from one another, and will always be rendered as Pascal.
Microsoft PowerToys version
0.86
Installation method
Dev build in Visual Studio
Running as admin
No
Area(s) with issue?
File Explorer: Preview Pane, Peek
Steps to reproduce
Please note: this is a minor issue, and I'm just reporting it to raise awareness and to include repro code so it may be tracked in the future.
The
monaco_languages.json
file includes a mapping of file extensions to language IDs. This allows for syntax highlighting on a per-language basis.There exist 3 cases where the same file extension is present for multiple languages. This may result in incorrect syntax highlighting in one of those cases.
The code to repro the issue is as follows:
(Setup a new Console application with this code as
Program.cs
and also copy in the currentmonaco_languages.json
file, setting that file to be copied to the output directory.)The results are:
The lookup for Monaco language matching in PowerToys will always pick the first match, so a file with a .pp extension will always be recognised as Pascal, even if it is a Puppet manifest file. (I assume the other 2 cases are OK, as the language IDs appear synonymous.)
I'm unsure what the resolution for this is without doing file introspection. That's probably unreasonable, especially for a single case such as this.
If it was decided to favour Puppet files over Pascal, the entry for Ruby should be moved before Pascal's in the file.
✔️ Expected Behavior
Files for Pascal and Puppet manifest files should be recognised as distinct, and highlighted differently by Monaco.
❌ Actual Behavior
As the files share the same extension, they cannot be distinguished from one another, and will always be rendered as Pascal.
Other Software
No response