diff --git a/far/changelog b/far/changelog index a712c4169f..f17d704c4e 100644 --- a/far/changelog +++ b/far/changelog @@ -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 diff --git a/far/console.cpp b/far/console.cpp index 51d9e83ed6..05c3f87b47 100644 --- a/far/console.cpp +++ b/far/console.cpp @@ -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. @@ -2176,6 +2176,20 @@ namespace console_detail if (Size.x >= std::numeric_limits::max() || Size.y >= std::numeric_limits::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; } diff --git a/far/vbuild.m4 b/far/vbuild.m4 index d100d6aa39..3107b0c7cb 100644 --- a/far/vbuild.m4 +++ b/far/vbuild.m4 @@ -1 +1 @@ -6345 +6346