From 383fed1abaa4017ee57d38330b20f00a0f85ff06 Mon Sep 17 00:00:00 2001 From: Chris Bradbury Date: Sat, 10 Sep 2022 16:32:18 +0100 Subject: [PATCH] Remove redundant 'equal to' comparison in `ViewPort.ValidateView` methods. The 'equal to' comparisons in the `ViewPort.ValidateViewX()` and `ViewPort.ValidateViewY()` methods are not required as the `ViewPort`s corresponding `view` attributes will be set equal to the right operand if the conditional resolves as true. The current behaviour results in the `view` attributes being set unnecessarily if it already equals the limit. --- views/view.go | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/views/view.go b/views/view.go index 993b3a36..db08e711 100644 --- a/views/view.go +++ b/views/view.go @@ -146,7 +146,7 @@ func (v *ViewPort) MakeVisible(x, y int) { // ValidateViewY ensures that the Y offset of the view port is limited so that // it cannot scroll away from the content. func (v *ViewPort) ValidateViewY() { - if v.viewy >= v.limy-v.height { + if v.viewy > v.limy-v.height { v.viewy = (v.limy - v.height) } if v.viewy < 0 { @@ -157,7 +157,7 @@ func (v *ViewPort) ValidateViewY() { // ValidateViewX ensures that the X offset of the view port is limited so that // it cannot scroll away from the content. func (v *ViewPort) ValidateViewX() { - if v.viewx >= v.limx-v.width { + if v.viewx > v.limx-v.width { v.viewx = (v.limx - v.width) } if v.viewx < 0 {