Skip to content
Merged
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
78 changes: 70 additions & 8 deletions WPILibInstaller-Avalonia/ViewModels/InstallPageViewModel.cs
Original file line number Diff line number Diff line change
Expand Up @@ -321,6 +321,41 @@ private static void SetIfNotSet(string key, object value, JObject settingsJson)
}
}

private static void SetIfNotSetIgnoreSync(string key, object value, JObject settingsJson)
{
SetIfNotSet(key, value, settingsJson);
IgnoreSync(key, settingsJson);
}

private static void IgnoreSync(string key, JObject settingsJson)
{
if (settingsJson.ContainsKey("settingsSync.ignoredSettings"))
{
JArray ignoredSettings = (JArray)settingsJson["settingsSync.ignoredSettings"]!;
Boolean keyFound = false;
foreach (JToken result in ignoredSettings)
{
if (result.Value<string>() != null)
{
if (result.Value<string>() == key)
{
keyFound = true;
}
}
}
if (!keyFound)
{
ignoredSettings.Add(key);
settingsJson["settingsSync.ignoredSettings"] = ignoredSettings;
}
}
else
{
JArray ignoredSettings = [key];
settingsJson["settingsSync.ignoredSettings"] = ignoredSettings;
}
}

private async Task ConfigureVsCodeSettings()
{
if (!vsInstallProvider.Model.InstallExtensions) return;
Expand Down Expand Up @@ -359,14 +394,14 @@ private async Task ConfigureVsCodeSettings()
}

SetIfNotSet("java.jdt.ls.java.home", Path.Combine(homePath, "jdk"), settingsJson);
SetIfNotSet("extensions.autoUpdate", false, settingsJson);
SetIfNotSet("extensions.autoCheckUpdates", false, settingsJson);
SetIfNotSet("extensions.ignoreRecommendations", true, settingsJson);
SetIfNotSet("extensions.showRecommendationsOnlyOnDemand", true, settingsJson);
SetIfNotSet("update.mode", "none", settingsJson);
SetIfNotSet("update.showReleaseNotes", false, settingsJson);
SetIfNotSet("java.completion.matchCase", "off", settingsJson);
SetIfNotSet("workbench.secondarySideBar.defaultVisibility", "hidden", settingsJson);
SetIfNotSetIgnoreSync("extensions.autoUpdate", false, settingsJson);
SetIfNotSetIgnoreSync("extensions.autoCheckUpdates", false, settingsJson);
SetIfNotSetIgnoreSync("extensions.ignoreRecommendations", true, settingsJson);
SetIfNotSetIgnoreSync("extensions.showRecommendationsOnlyOnDemand", true, settingsJson);
SetIfNotSetIgnoreSync("update.mode", "none", settingsJson);
SetIfNotSetIgnoreSync("update.showReleaseNotes", false, settingsJson);
SetIfNotSetIgnoreSync("java.completion.matchCase", "off", settingsJson);
SetIfNotSetIgnoreSync("workbench.secondarySideBar.defaultVisibility", "hidden", settingsJson);

string os;
string path_seperator;
Expand Down Expand Up @@ -416,6 +451,7 @@ private async Task ConfigureVsCodeSettings()
}
}
}
IgnoreSync("terminal.integrated.env." + os, settingsJson);

if (settingsJson.ContainsKey("java.configuration.runtimes"))
{
Expand Down Expand Up @@ -463,6 +499,32 @@ private async Task ConfigureVsCodeSettings()
settingsJson["java.configuration.runtimes"] = javaConfigProps;
}

if (settingsJson.ContainsKey("settingsSync.ignoredExtensions"))
{
JArray ignoredExtensions = (JArray)settingsJson["settingsSync.ignoredExtensions"]!;
Boolean keyFound = false;
foreach (JToken result in ignoredExtensions)
{
if (result.Value<string>() != null)
{
if (result.Value<string>() == "wpilibsuite.vscode-wpilib")
{
keyFound = true;
}
}
}
if (!keyFound)
{
ignoredExtensions.Add("wpilibsuite.vscode-wpilib");
settingsJson["settingsSync.ignoredExtensions"] = ignoredExtensions;
}
}
else
{
JArray ignoredExtensions = ["wpilibsuite.vscode-wpilib"];
settingsJson["settingsSync.ignoredExtensions"] = ignoredExtensions;
}

var serialized = JsonConvert.SerializeObject(settingsJson, Formatting.Indented);
await File.WriteAllTextAsync(settingsFile, serialized);
}
Expand Down