Fix implicitly narrowing conversion in textBuffer (#9972)

Explicitly using `SHORT` instead of `auto` to prevent `int -> short` narrowing.
This commit is contained in:
Chester Liu 2021-04-29 00:45:29 +08:00 committed by GitHub
parent 4457a6dedc
commit c5fcbede78
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23

View file

@ -850,7 +850,7 @@ bool TextBuffer::IsDoubleWidthLine(const size_t row) const
SHORT TextBuffer::GetLineWidth(const size_t row) const
{
// Use shift right to quickly divide the width by 2 for double width lines.
const auto scale = IsDoubleWidthLine(row) ? 1 : 0;
const SHORT scale = IsDoubleWidthLine(row) ? 1 : 0;
return GetSize().Width() >> scale;
}
@ -863,14 +863,14 @@ COORD TextBuffer::ClampPositionWithinLine(const COORD position) const
COORD TextBuffer::ScreenToBufferPosition(const COORD position) const
{
// Use shift right to quickly divide the X pos by 2 for double width lines.
const auto scale = IsDoubleWidthLine(position.Y) ? 1 : 0;
const SHORT scale = IsDoubleWidthLine(position.Y) ? 1 : 0;
return { position.X >> scale, position.Y };
}
COORD TextBuffer::BufferToScreenPosition(const COORD position) const
{
// Use shift left to quickly multiply the X pos by 2 for double width lines.
const auto scale = IsDoubleWidthLine(position.Y) ? 1 : 0;
const SHORT scale = IsDoubleWidthLine(position.Y) ? 1 : 0;
return { position.X << scale, position.Y };
}