From 5af6a17d1a23ee356cc496330cfbd99110e2caf3 Mon Sep 17 00:00:00 2001
From: Deon George <deon@dege.au>
Date: Sun, 8 Sep 2024 21:23:11 +1000
Subject: [PATCH] Fix page rendering when a leftbox is rendered

---
 app/Classes/Page.php | 6 +++---
 1 file changed, 3 insertions(+), 3 deletions(-)

diff --git a/app/Classes/Page.php b/app/Classes/Page.php
index f655a5d..f78cff3 100644
--- a/app/Classes/Page.php
+++ b/app/Classes/Page.php
@@ -332,13 +332,13 @@ class Page
 							$subtext = substr($this->text,$current_pos,$space_pos);
 						}
 
-					// If the reset of the string will fit on the current line
-					} elseif ($text_length-$current_pos < static::MSG_WIDTH-$buffer) {
+					// If the rest of the string will fit on the current line
+					} elseif ($text_length-$current_pos < static::MSG_WIDTH-$this->x-$buffer) {
 						$subtext = substr($this->text,$current_pos);
 
 					// Get the next lines worth of chars, breaking on a space
 					} else {
-						$subtext = $this->text_substr(substr($this->text,$current_pos),static::MSG_WIDTH-$buffer);
+						$subtext = $this->text_substr(substr($this->text,$current_pos),static::MSG_WIDTH-$this->x-$buffer);
 
 						// Include the text up to the last space
 						if (substr($this->text,$current_pos+strlen($subtext),1) !== ' ')