Repository: microsoft/terminal
File: src/renderer/dx/CustomTextRenderer.cpp (C++)

Code before:
    if (rect.top > textRunBounds.bottom ||
        rect.bottom <= textRunBounds.top ||
        rect.left > textRunBounds.right ||
        rect.right <= textRunBounds.left)
    {
        return S_FALSE;
    }

    CursorPaintType paintType = CursorPaintType::Fill;
    Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> brush{ drawingContext.foregroundBrush };

    if (options.fUseColor)
    {
        // Make sure to make the cursor opaque
        RETURN_IF_FAILED(d2dContext->CreateSolidColorBrush(til::color{ OPACITY_OPAQUE | options.cursorColor },
                                                           &brush));
    }

    switch (options.cursorType)
    {
    case CursorType::Legacy:
    {
        // Enforce min/max cursor height
        ULONG ulHeight = std::clamp(options.ulCursorHeightPercent, MinCursorHeightPercent, MaxCursorHeightPercent);
        ulHeight = (glyphSize.height<ULONG>() * ulHeight) / 100;
        rect.top = rect.bottom - ulHeight;
        break;
    }
    case CursorType::VerticalBar:
    {
        // It can't be wider than one cell or we'll have problems in invalidation, so restrict here.
        // It's either the left + the proposed width from the ease of access setting, or
        // it's the right edge of the block cursor as a maximum.
        rect.right = std::min(rect.right, rect.left + options.cursorPixelWidth);
        break;
    }
    case CursorType::Underscore:
    {
        rect.top = rect.bottom - 1;
        break;
    }
    case CursorType::DoubleUnderscore:
    {
        // Use rect for lower line.
        rect.top = rect.bottom - 1;

        // Draw upper line directly.
        D2D1_RECT_F upperLine = rect;
        upperLine.top -= 2;
        upperLine.bottom -= 2;
        d2dContext->FillRectangle(upperLine, brush.Get());

Review comment (suggestion):
@carlos-zamora, @zadjii-msft what if we restrict the minimum cursor height value to 1px? On values less than 25 the cursor is getting smaller until it reaches the 1px height. If one decreases the value further, it won't change anything. 

If you think it's ok, I'll also update the docs.

Code after:
    if (rect.top > textRunBounds.bottom ||
        rect.bottom <= textRunBounds.top ||
        rect.left > textRunBounds.right ||
        rect.right <= textRunBounds.left)
    {
        return S_FALSE;
    }

    CursorPaintType paintType = CursorPaintType::Fill;
    Microsoft::WRL::ComPtr<ID2D1SolidColorBrush> brush{ drawingContext.foregroundBrush };

    if (options.fUseColor)
    {
        // Make sure to make the cursor opaque
        RETURN_IF_FAILED(d2dContext->CreateSolidColorBrush(til::color{ OPACITY_OPAQUE | options.cursorColor },
                                                           &brush));
    }

    switch (options.cursorType)
    {
    case CursorType::Legacy:
    {
        // Enforce min/max cursor height
        ULONG ulHeight = std::clamp(options.ulCursorHeightPercent, MinCursorHeightPercent, MaxCursorHeightPercent);
        ulHeight = (glyphSize.height<ULONG>() * ulHeight) / 100;
        ulHeight = std::max(ulHeight, MinCursorHeightPixels); // No smaller than 1px

        rect.top = rect.bottom - ulHeight;
        break;
    }
    case CursorType::VerticalBar:
    {
        // It can't be wider than one cell or we'll have problems in invalidation, so restrict here.
        // It's either the left + the proposed width from the ease of access setting, or
        // it's the right edge of the block cursor as a maximum.
        rect.right = std::min(rect.right, rect.left + options.cursorPixelWidth);
        break;
    }
    case CursorType::Underscore:
    {
        rect.top = rect.bottom - 1;
        break;
    }
    case CursorType::DoubleUnderscore:
    {
        // Use rect for lower line.
        rect.top = rect.bottom - 1;

        // Draw upper line directly.
        D2D1_RECT_F upperLine = rect;
        upperLine.top -= 2;