flake: fix compiler warning

GCC was complaining, rightfully, about mixed-sign comparisons in there.
I removed some extra sign mixing too.

Change-Id: I949a618c7405c23d4dc3fd17440ea2d7b5c22c9d
This commit is contained in:
jade 2024-08-20 16:13:17 -07:00
parent e727dbc3a3
commit c25c43d8c8

View file

@ -1275,13 +1275,15 @@ struct CmdFlakeShow : FlakeCommand, MixJSON
// FIXME: handle utf8 visible width properly once we get KJ which has utf8 support // FIXME: handle utf8 visible width properly once we get KJ which has utf8 support
// technically filterANSIEscapes knows how to do this but there is absolutely // technically filterANSIEscapes knows how to do this but there is absolutely
// no clear usage of it that would actually let us do this layout. // no clear usage of it that would actually let us do this layout.
int spaceForDescription = screenWidth - output.size() - quotesAndSepsWidth; assert(output.size() < std::numeric_limits<int>::max());
int spaceForDescription = screenWidth - int(output.size()) - quotesAndSepsWidth;
if (spaceForDescription <= 0) { if (spaceForDescription <= 0) {
// do nothing, it is going to wrap no matter what, and it's better to output *something* // do nothing, it is going to wrap no matter what, and it's better to output *something*
} else { } else {
const char *ellipsis = ""; const char *ellipsis = "";
if (spaceForDescription < firstLineDesc.size()) { assert(firstLineDesc.size() < std::numeric_limits<int>::max());
if (spaceForDescription < int(firstLineDesc.size())) {
// subtract one to make space for the ellipsis // subtract one to make space for the ellipsis
firstLineDesc.resize(spaceForDescription - 1); firstLineDesc.resize(spaceForDescription - 1);
ellipsis = ""; ellipsis = "";