Repository: microsoft/terminal
File: src/terminal/adapter/adaptDispatchGraphics.cpp (C++)

Code before:
        return 1 + _SetRgbColorsHelper(options.subspan(optionIndex + 1), attr, false);
    default:
        return 1;
    }
}

// Routine Description:
// - Helper to apply a single graphic rendition option with sub parameters to an attribute.
// Arguments:
// - option - An option to apply.
// - subParams - Sub parameters associated with the option.
// - attr - The attribute that will be updated with the applied option.
// Return Value:
// - <None>
void AdaptDispatch::_ApplyGraphicsOptionAlt(const VTParameter option,
                                            const VTSubParameters subParams,
                                            TextAttribute& attr) noexcept
{
    // here, we apply our "best effort" rule, while handling sub params if we don't
    // recognise the parameter substring (parameter and it's sub parameters) then
    // we should just skip over them.
    switch (option)
    {
    case ForegroundExtended:
    case BackgroundExtended:
        _SetRgbColorsHelperAlt(option, subParams, attr);
        break;
    default:
        /* do nothing */
        break;
    }
}

// Routine Description:
// - Helper to apply a number of graphic rendition options to an attribute.
// Arguments:
// - options - An array of options that will be applied in sequence.
// - attr - The attribute that will be updated with the applied options.
// Return Value:
// - <none>
void AdaptDispatch::_ApplyGraphicsOptions(const VTParameters options,
                                          TextAttribute& attr) noexcept
{
    for (size_t i = 0; i < options.size();)
    {
        i += _ApplyGraphicsOption(options, i, attr);
    }
}

// Routine Description:
// - SGR - Modifies the graphical rendering options applied to the next

Review comment (refactor):
Instead of passing the `option` through to `_SetRgbColorsHelperAlt`, would it perhaps be easier to pass through the `isForeground` state as a parameter instead, the same way the `_SetRgbColorsHelper` method works? So this switch would look something like this:

```cpp
case ForegroundExtended:
    _SetRgbColorsHelperAlt(subParams, attr, true);
    break;
case BackgroundExtended:
    _SetRgbColorsHelperAlt(subParams, attr, false);
    break
```

Code after:
    case BrightBackgroundRed:
        attr.SetIndexedBackground(TextColor::BRIGHT_RED);
        return 1;
    case BrightBackgroundMagenta:
        attr.SetIndexedBackground(TextColor::BRIGHT_MAGENTA);
        return 1;
    case BrightBackgroundYellow:
        attr.SetIndexedBackground(TextColor::BRIGHT_YELLOW);
        return 1;
    case BrightBackgroundWhite:
        attr.SetIndexedBackground(TextColor::BRIGHT_WHITE);
        return 1;
    case ForegroundExtended:
        return 1 + _SetRgbColorsHelper(options.subspan(optionIndex + 1), attr, true);
    case BackgroundExtended:
        return 1 + _SetRgbColorsHelper(options.subspan(optionIndex + 1), attr, false);
    default:
        return 1;
    }
}

// Routine Description:
// - Helper to apply a single graphic rendition option with sub parameters to an attribute.
// Arguments:
// - option - An option to apply.
// - subParams - Sub parameters associated with the option.
// - attr - The attribute that will be updated with the applied option.
// Return Value:
// - <None>
void AdaptDispatch::_ApplyGraphicsOptionWithSubParams(const VTParameter option,
                                                      const VTSubParameters subParams,
                                                      TextAttribute& attr) noexcept
{
    // here, we apply our "best effort" rule, while handling sub params if we don't
    // recognise the parameter substring (parameter and it's sub parameters) then
    // we should just skip over them.
    switch (option)
    {
    case ForegroundExtended:
    case BackgroundExtended:
        _SetRgbColorsHelperFromSubParams(option, subParams, attr);
        break;
    default:
        /* do nothing */
        break;
    }
}

// Routine Description:
// - Helper to apply a number of graphic rendition options to an attribute.
// Arguments: