Skip to content

Commit

Permalink
Browse files Browse the repository at this point in the history
  • Loading branch information
alabuzhev committed Jul 15, 2024
1 parent 8d1fc4d commit 99e4af4
Show file tree
Hide file tree
Showing 3 changed files with 22 additions and 3 deletions.
5 changes: 5 additions & 0 deletions far/changelog
Original file line number Diff line number Diff line change
@@ -1,3 +1,8 @@
--------------------------------------------------------------------------------
drkns 2024-07-15 20:17:50+01:00 - build 6346

1. microsoft/terminal#10337 again.

--------------------------------------------------------------------------------
drkns 2024-07-08 22:55:36+01:00 - build 6345

Expand Down
18 changes: 16 additions & 2 deletions far/console.cpp
Original file line number Diff line number Diff line change
Expand Up @@ -2157,8 +2157,8 @@ namespace console_detail
{
// https://github.com/microsoft/terminal/issues/10337

// As of 7 Oct 2022 GetLargestConsoleWindowSize is broken in WT.
// It takes the current screen resolution and divides it by an inadequate font size, e.g. 1x16.
// As of 15 Jul 2024 GetLargestConsoleWindowSize is broken in WT.
// It takes the current screen size in pixels and divides it by an inadequate font size, e.g. 1x16 or 1x1.

// It is unlikely that it is ever gonna be fixed, so we do a few very basic checks here to filter out obvious rubbish.

Expand All @@ -2176,6 +2176,20 @@ namespace console_detail
if (Size.x >= std::numeric_limits<SHORT>::max() || Size.y >= std::numeric_limits<SHORT>::max())
return false;

// If we got here, it is either legit or they used some fallback 1x1 font and the proportions are not screwed enough to fail the checks above.
if (const auto Monitor = MonitorFromWindow(::console.GetWindow(), MONITOR_DEFAULTTONEAREST))
{
if (MONITORINFO Info{ sizeof(Info) }; GetMonitorInfo(Monitor, &Info))
{
// The smallest selectable in the UI font is 5x2. Anything smaller than that is likely rubbish and unreadable anyway.
if (const auto AssumedFontHeight = (Info.rcWork.bottom - Info.rcWork.top) / Size.y; AssumedFontHeight < 5)
return false;

if (const auto AssumedFontWidth = (Info.rcWork.right - Info.rcWork.left) / Size.x; AssumedFontWidth < 2)
return false;
}
}

return true;
}

Expand Down
2 changes: 1 addition & 1 deletion far/vbuild.m4
Original file line number Diff line number Diff line change
@@ -1 +1 @@
6345
6346

0 comments on commit 99e4af4

Please sign in to comment.