diff --git a/far/vmenu.cpp b/far/vmenu.cpp index 5d4a733902..792a64cf3b 100644 --- a/far/vmenu.cpp +++ b/far/vmenu.cpp @@ -407,15 +407,13 @@ namespace if (Shift < 0) { - if (Right <= 0) return 0; - const auto NegativeLeftShiftLimit{ 1 - Right }; + const auto NegativeLeftShiftLimit{ std::min(1 - Right, 0) }; const auto PositiveGapRightOfTextArea{ std::max(Left - TextAreaWidth, 0) }; return std::max(Shift - PositiveGapRightOfTextArea, NegativeLeftShiftLimit); } if (Shift > 0) { - if (TextAreaWidth <= Left) return 0; - const auto PositiveRightShiftLimit{ TextAreaWidth - Left - 1 }; + const auto PositiveRightShiftLimit{ std::max(TextAreaWidth - Left - 1, 0) }; const auto NegativeGapLeftOfTextArea{ std::min(Right, 0) }; return std::min(Shift - NegativeGapLeftOfTextArea, PositiveRightShiftLimit); } @@ -423,19 +421,17 @@ namespace //if (Shift < 0) //{ - // if (Right <= 0) - // return 0; - // if (Left >= TextAreaWidth) - // return std::max(Shift - (Left - TextAreaWidth), 1 - Right); - // return std::max(Shift, 1 - Right); + // if (Right <= 0) return 0; + // const auto NegativeLeftShiftLimit{ 1 - Right }; + // const auto PositiveGapRightOfTextArea{ std::max(Left - TextAreaWidth, 0) }; + // return std::max(Shift - PositiveGapRightOfTextArea, NegativeLeftShiftLimit); //} //if (Shift > 0) //{ - // if (Right <= 0) - // return std::min(Shift - Right, TextAreaWidth - Left - 1); - // if (Left >= TextAreaWidth) - // return 0; - // return std::min(Shift, TextAreaWidth - Left - 1); + // if (TextAreaWidth <= Left) return 0; + // const auto PositiveRightShiftLimit{ TextAreaWidth - Left - 1 }; + // const auto NegativeGapLeftOfTextArea{ std::min(Right, 0) }; + // return std::min(Shift - NegativeGapLeftOfTextArea, PositiveRightShiftLimit); //} //return 0; }