Repository: microsoft/terminal
File: src/cascadia/UIMarkdown/MarkdownToXaml.cpp (C++)

Code before:
}

MarkdownToXaml::MarkdownToXaml(const winrt::hstring& baseUrl) :
    _baseUri{ baseUrl }
{
    _root.IsTextSelectionEnabled(true);
    _root.TextWrapping(WUX::TextWrapping::WrapWholeWords);
}

WUX::Documents::Paragraph MarkdownToXaml::_CurrentParagraph()
{
    if (_lastParagraph == nullptr)
    {
        _lastParagraph = WUX::Documents::Paragraph{};
        if (_indent > 0)
        {
            // If we're in a list, we will start this paragraph with a bullet
            // point. That bullet point will be added as part of the actual text
            // of the paragraph, but we want the real text of the paragraph all
            // aligned. So we will _de-indent_ the first line, to give us space
            // for the bullet.
            if (_indent - _blockQuoteDepth > 0)
            {
                _lastParagraph.TextIndent(-WidthOfBulletPoint);
            }
            _lastParagraph.Margin(WUX::ThicknessHelper::FromLengths(gsl::narrow<double>(IndentWidth) * _indent, 0, 0, 0));
        }
        _root.Blocks().Append(_lastParagraph);
    }
    return _lastParagraph;
}
WUX::Documents::Run MarkdownToXaml::_CurrentRun()
{
    if (_lastRun == nullptr)
    {
        _lastRun = WUX::Documents::Run{};
        _CurrentSpan().Inlines().Append(_lastRun);
    }
    return _lastRun;
}
WUX::Documents::Span MarkdownToXaml::_CurrentSpan()
{
    if (_lastSpan == nullptr)
    {
        _lastSpan = WUX::Documents::Span{};
        _CurrentParagraph().Inlines().Append(_lastSpan);
    }
    return _lastSpan;
}
WUX::Documents::Run MarkdownToXaml::_NewRun()
{

Review comment (suggestion):
This probably works, but is most likely not what you actually intended.
What `gsl::narrow` does is something like that:
```cs
let narrowed = (TargetType)original_value;
let converted_back = (OriginalType)narrowed;
if (converted_back != original_value) {
    throw;
}
return narrowed;
```

In other words, this will throw if there was no accurate representation as a `double`. This is easy to show with floats, because if you run `gsl::narrow<float>(0xffffffff)` it'll throw as it'll actually turn into 4.2949673e9 which is nowhere near 4294967295.

The solution is to just use `static_cast`.

Code after:
}

MarkdownToXaml::MarkdownToXaml(const winrt::hstring& baseUrl) :
    _baseUri{ baseUrl }
{
    _root.IsTextSelectionEnabled(true);
    _root.TextWrapping(WUX::TextWrapping::WrapWholeWords);
}

WUX::Documents::Paragraph MarkdownToXaml::_CurrentParagraph()
{
    if (_lastParagraph == nullptr)
    {
        _lastParagraph = WUX::Documents::Paragraph{};
        if (_indent > 0)
        {
            // If we're in a list, we will start this paragraph with a bullet
            // point. That bullet point will be added as part of the actual text
            // of the paragraph, but we want the real text of the paragraph all
            // aligned. So we will _de-indent_ the first line, to give us space
            // for the bullet.
            if (_indent - _blockQuoteDepth > 0)
            {
                _lastParagraph.TextIndent(-WidthOfBulletPoint);
            }
            _lastParagraph.Margin(WUX::ThicknessHelper::FromLengths(static_cast<double>(IndentWidth) * _indent, 0, 0, 0));
        }
        _root.Blocks().Append(_lastParagraph);
    }
    return _lastParagraph;
}
WUX::Documents::Run MarkdownToXaml::_CurrentRun()
{
    if (_lastRun == nullptr)
    {
        _lastRun = WUX::Documents::Run{};
        _CurrentSpan().Inlines().Append(_lastRun);
    }
    return _lastRun;
}
WUX::Documents::Span MarkdownToXaml::_CurrentSpan()
{
    if (_lastSpan == nullptr)
    {
        _lastSpan = WUX::Documents::Span{};
        _CurrentParagraph().Inlines().Append(_lastSpan);
    }
    return _lastSpan;
}
WUX::Documents::Run MarkdownToXaml::_NewRun()
{