Repository: microsoft/PowerToys
File: src/modules/launcher/Plugins/Microsoft.PowerToys.Run.Plugin.WindowsTerminal/Helpers/TerminalHelper.cs (C#)

Code before:

using System;
using System.Collections.Generic;
using System.Text.Json;

namespace Microsoft.PowerToys.Run.Plugin.WindowsTerminal.Helpers
{
    public static class TerminalHelper
    {
        /// <summary>
        /// Return the arguments for launch Windows Terminal
        /// </summary>
        /// <param name="profileName">Name of the Terminal profile</param>
        /// <param name="openNewTab">Whether to launch the profile in a new tab</param>
        /// <param name="openQuake">Whether to launch the profile in the quake window</param>
        public static string GetArguments(string profileName, bool openNewTab, bool openQuake)
        {
            var argsPrefix = string.Empty;
            if (openQuake)
            {
                argsPrefix = "--window _quake nt";
            }
            else if (openNewTab)
            {
                argsPrefix = "--window 0 nt";
            }

            return $"{argsPrefix} --profile \"{profileName}\"";
        }

        /// <summary>
        /// Return a list of profiles for the Windows Terminal
        /// </summary>
        /// <param name="terminal">Windows Terminal package</param>
        /// <param name="settingsJson">Content of the settings JSON file of the Terminal</param>
        public static List<TerminalProfile> ParseSettings(TerminalPackage terminal, string settingsJson)
        {
            var profiles = new List<TerminalProfile>();

            var options = new JsonDocumentOptions
            {
                CommentHandling = JsonCommentHandling.Skip,
            };

            var json = JsonDocument.Parse(settingsJson, options);
            JsonElement profilesList;

            json.RootElement.TryGetProperty("profiles", out JsonElement profilesElement);
            if (profilesElement.ValueKind == JsonValueKind.Object)
            {
                profilesElement.TryGetProperty("list", out profilesList);

Review comment (suggestion):
if both is true we should at least log an error and maybe show an error instead opening wt. The normal user don't knows what has priority and might be confused if enable NewTab doesn't work.

Code after:

using System;
using System.Collections.Generic;
using System.Text.Json;

namespace Microsoft.PowerToys.Run.Plugin.WindowsTerminal.Helpers
{
    public static class TerminalHelper
    {
        /// <summary>
        /// Return the arguments for launch Windows Terminal
        /// </summary>
        /// <param name="profileName">Name of the Terminal profile</param>
        /// <param name="openNewTab">Whether to launch the profile in a new tab</param>
        /// <param name="openQuake">Whether to launch the profile in the quake window</param>
        public static string GetArguments(string profileName, bool openNewTab, bool openQuake)
        {
            var argsPrefix = string.Empty;
            if (openQuake)
            {
                // It does not matter whether we add the "nt" argument here; when specifying the
                // _quake window explicitly, Windows Terminal will always open a new tab when the
                // window exists, or open a new window when it does not yet.
                argsPrefix = "--window _quake";
            }
            else if (openNewTab)
            {
                argsPrefix = "--window 0 nt";
            }

            return $"{argsPrefix} --profile \"{profileName}\"";
        }

        /// <summary>
        /// Return a list of profiles for the Windows Terminal
        /// </summary>
        /// <param name="terminal">Windows Terminal package</param>
        /// <param name="settingsJson">Content of the settings JSON file of the Terminal</param>
        public static List<TerminalProfile> ParseSettings(TerminalPackage terminal, string settingsJson)
        {
            var profiles = new List<TerminalProfile>();

            var options = new JsonDocumentOptions
            {
                CommentHandling = JsonCommentHandling.Skip,
            };

            var json = JsonDocument.Parse(settingsJson, options);
            JsonElement profilesList;

            json.RootElement.TryGetProperty("profiles", out JsonElement profilesElement);