Repository: microsoft/terminal
File: src/cascadia/TerminalSettingsEditor/ProfileViewModel.cpp (C++)

Code before:
    // Method Description:
    // - Check if any bell sounds share the same name.
    //   If they do, mark them so that they show the directory path in the UI
    void ProfileViewModel::_MarkDuplicateBellSoundDirectories()
    {
        for (uint32_t i = 0; i < _CurrentBellSounds.Size(); i++)
        {
            auto soundA = _CurrentBellSounds.GetAt(i);
            for (uint32_t j = i + 1; j < _CurrentBellSounds.Size(); j++)
            {
                auto soundB = _CurrentBellSounds.GetAt(j);
                if (soundA.DisplayPath() == soundB.DisplayPath())
                {
                    get_self<BellSoundViewModel>(soundA)->ShowDirectory(true);
                    get_self<BellSoundViewModel>(soundB)->ShowDirectory(true);
                }
            }
        }
    }

    BellSoundViewModel::BellSoundViewModel(const Model::IMediaResource& resource) :
        _resource{ resource }
    {
        if (_resource.Ok() && _resource.Path() != _resource.Resolved())
        {
            // If the resource was resolved to something other than its path, show the path!
            _ShowDirectory = true;
        }
    }

    hstring BellSoundViewModel::DisplayPath() const
    {
        if (_resource.Ok())
        {
            // filename; start from the resolved path to show where it actually landed
            auto resolvedPath{ _resource.Resolved() };
            const std::filesystem::path filePath{ std::wstring_view{ resolvedPath } };
            return hstring{ filePath.filename().wstring() };
        }
        return _resource.Path();
    }

    hstring BellSoundViewModel::SubText() const
    {
        if (_resource.Ok())
        {
            // Directory
            auto resolvedPath{ _resource.Resolved() };
            const std::filesystem::path filePath{ std::wstring_view{ resolvedPath } };
            return hstring{ filePath.parent_path().wstring() };
        }

Review comment (suggestion):
@carlos-zamora since you wrote bell sounds, you might care about this. it means that if you use a relative path to your bell sound file, the settings UI will always display the folder it _resolved_ to

Code after:
    // - Check if any bell sounds share the same name.
    //   If they do, mark them so that they show the directory path in the UI
    void ProfileViewModel::_MarkDuplicateBellSoundDirectories()
    {
        for (uint32_t i = 0; i < _CurrentBellSounds.Size(); i++)
        {
            auto soundA = _CurrentBellSounds.GetAt(i);
            for (uint32_t j = i + 1; j < _CurrentBellSounds.Size(); j++)
            {
                auto soundB = _CurrentBellSounds.GetAt(j);
                if (soundA.DisplayPath() == soundB.DisplayPath())
                {
                    get_self<BellSoundViewModel>(soundA)->ShowDirectory(true);
                    get_self<BellSoundViewModel>(soundB)->ShowDirectory(true);
                }
            }
        }
    }

    BellSoundViewModel::BellSoundViewModel(const Model::IMediaResource& resource) :
        _resource{ resource }
    {
        if (_resource.Ok() && _resource.Path() != _resource.Resolved())
        {
            // If the resource was resolved to something other than its path, show the path!
            _ShowDirectory = true;
        }
    }

    hstring BellSoundViewModel::DisplayPath() const
    {
        if (_resource.Ok())
        {
            // filename; start from the resolved path to show where it actually landed
            auto resolvedPath{ _resource.Resolved() };
            const std::filesystem::path filePath{ std::wstring_view{ resolvedPath } };
            return hstring{ filePath.filename().wstring() };
        }
        return _resource.Path();
    }

    hstring BellSoundViewModel::SubText() const
    {
        if (_resource.Ok())
        {
            // Directory
            auto resolvedPath{ _resource.Resolved() };
            const std::filesystem::path filePath{ std::wstring_view{ resolvedPath } };
            return hstring{ filePath.parent_path().wstring() };
        }
        return RS_(L"Profile_BellSoundNotFound");