Repository: microsoft/PowerToys
File: src/modules/EnvironmentVariables/EnvironmentVariables/ViewModels/MainViewModel.cs (C#)

Code before:
                    }
                }

                Profiles = new ObservableCollection<ProfileVariablesSet>(profiles);
            }
            catch (Exception ex)
            {
                // Show some error
                Logger.LogError("Failed to load profiles.json file", ex);

                Profiles = new ObservableCollection<ProfileVariablesSet>();
            }
        }

        private void PopulateAppliedVariables()
        {
            LoadDefaultVariables();

            var variables = new List<Variable>();
            if (AppliedProfile != null)
            {
                variables = variables.Concat(AppliedProfile.Variables.Select(x => new Variable(x.Name, Environment.ExpandEnvironmentVariables(x.Values), VariablesSetType.Profile)).OrderBy(x => x.Name)).ToList();
            }

            variables = variables.Concat(UserDefaultSet.Variables.Select(x => new Variable(x.Name, Environment.ExpandEnvironmentVariables(x.Values), VariablesSetType.User)).OrderBy(x => x.Name))
                                 .Concat(SystemDefaultSet.Variables.Select(x => new Variable(x.Name, Environment.ExpandEnvironmentVariables(x.Values), VariablesSetType.System)).OrderBy(x => x.Name))
                                 .ToList();

            // Handle PATH variable - add USER value to the end of the SYSTEM value
            var profilePath = variables.Where(x => x.Name.Equals("PATH", StringComparison.OrdinalIgnoreCase) && x.ParentType == VariablesSetType.Profile).FirstOrDefault();
            var userPath = variables.Where(x => x.Name.Equals("PATH", StringComparison.OrdinalIgnoreCase) && x.ParentType == VariablesSetType.User).FirstOrDefault();
            var systemPath = variables.Where(x => x.Name.Equals("PATH", StringComparison.OrdinalIgnoreCase) && x.ParentType == VariablesSetType.System).FirstOrDefault();

            if (systemPath != null)
            {
                var clone = systemPath.Clone();
                clone.ParentType = VariablesSetType.Path;

                if (userPath != null)
                {
                    clone.Values += ";" + userPath.Values;
                    variables.Remove(userPath);
                }

                if (profilePath != null)
                {
                    variables.Remove(profilePath);
                }

                variables.Insert(variables.IndexOf(systemPath), clone);
                variables.Remove(systemPath);

Review comment (suggestion):
```suggestion
            // Variables are expanded to be shown in the applied variables section, so the user sees their actual values.
            variables = variables.Concat(UserDefaultSet.Variables.Select(x => new Variable(x.Name, Environment.ExpandEnvironmentVariables(x.Values), VariablesSetType.User)).OrderBy(x => x.Name))
```

Code after:
                    }
                }

                Profiles = new ObservableCollection<ProfileVariablesSet>(profiles);
            }
            catch (Exception ex)
            {
                // Show some error
                Logger.LogError("Failed to load profiles.json file", ex);

                Profiles = new ObservableCollection<ProfileVariablesSet>();
            }
        }

        private void PopulateAppliedVariables()
        {
            LoadDefaultVariables();

            var variables = new List<Variable>();
            if (AppliedProfile != null)
            {
                variables = variables.Concat(AppliedProfile.Variables.Select(x => new Variable(x.Name, Environment.ExpandEnvironmentVariables(x.Values), VariablesSetType.Profile)).OrderBy(x => x.Name)).ToList();
            }

            // Variables are expanded to be shown in the applied variables section, so the user sees their actual values.
            variables = variables.Concat(UserDefaultSet.Variables.Select(x => new Variable(x.Name, Environment.ExpandEnvironmentVariables(x.Values), VariablesSetType.User)).OrderBy(x => x.Name))
                                 .Concat(SystemDefaultSet.Variables.Select(x => new Variable(x.Name, Environment.ExpandEnvironmentVariables(x.Values), VariablesSetType.System)).OrderBy(x => x.Name))
                                 .ToList();

            // Handle PATH variable - add USER value to the end of the SYSTEM value
            var profilePath = variables.Where(x => x.Name.Equals("PATH", StringComparison.OrdinalIgnoreCase) && x.ParentType == VariablesSetType.Profile).FirstOrDefault();
            var userPath = variables.Where(x => x.Name.Equals("PATH", StringComparison.OrdinalIgnoreCase) && x.ParentType == VariablesSetType.User).FirstOrDefault();
            var systemPath = variables.Where(x => x.Name.Equals("PATH", StringComparison.OrdinalIgnoreCase) && x.ParentType == VariablesSetType.System).FirstOrDefault();

            if (systemPath != null)
            {
                var clone = systemPath.Clone();
                clone.ParentType = VariablesSetType.Path;

                if (userPath != null)
                {
                    clone.Values += ";" + userPath.Values;
                    variables.Remove(userPath);
                }

                if (profilePath != null)
                {
                    variables.Remove(profilePath);
                }

                variables.Insert(variables.IndexOf(systemPath), clone);