mirror of
https://github.com/microsoft/PowerToys.git
synced 2026-04-07 03:36:44 +02:00
[DeveloperPreview]Fix case issue and file in use issue (#17732)
This commit is contained in:
@@ -3,6 +3,7 @@
|
|||||||
// See the LICENSE file in the project root for more information.
|
// See the LICENSE file in the project root for more information.
|
||||||
|
|
||||||
using System;
|
using System;
|
||||||
|
using System.Globalization;
|
||||||
using System.IO;
|
using System.IO;
|
||||||
using System.Linq;
|
using System.Linq;
|
||||||
using System.Text.Json;
|
using System.Text.Json;
|
||||||
@@ -18,9 +19,16 @@ namespace Microsoft.PowerToys.PreviewHandler.Monaco
|
|||||||
/// <returns>The monaco language id</returns>
|
/// <returns>The monaco language id</returns>
|
||||||
public static string GetLanguage(string fileExtension)
|
public static string GetLanguage(string fileExtension)
|
||||||
{
|
{
|
||||||
|
fileExtension = fileExtension.ToLower(CultureInfo.CurrentCulture);
|
||||||
try
|
try
|
||||||
{
|
{
|
||||||
JsonDocument languageListDocument = JsonDocument.Parse(File.ReadAllText(Settings.AssemblyDirectory + "\\monaco_languages.json"));
|
JsonDocument languageListDocument;
|
||||||
|
using (StreamReader jsonFileReader = new StreamReader(new FileStream(Settings.AssemblyDirectory + "\\monaco_languages.json", FileMode.Open, FileAccess.Read, FileShare.ReadWrite)))
|
||||||
|
{
|
||||||
|
languageListDocument = JsonDocument.Parse(jsonFileReader.ReadToEnd());
|
||||||
|
jsonFileReader.Close();
|
||||||
|
}
|
||||||
|
|
||||||
JsonElement languageList = languageListDocument.RootElement.GetProperty("list");
|
JsonElement languageList = languageListDocument.RootElement.GetProperty("list");
|
||||||
foreach (JsonElement e in languageList.EnumerateArray())
|
foreach (JsonElement e in languageList.EnumerateArray())
|
||||||
{
|
{
|
||||||
|
|||||||
Reference in New Issue
Block a user