From 1d639e4b278e4f1743c9034a75ecd70eb7645574 Mon Sep 17 00:00:00 2001 From: gambas Date: Fri, 7 Dec 2018 01:02:49 +0100 Subject: [PATCH] String.Left() sometimes fails. Print a warning if such a case is detected. [GB.FORM.TERMINAL] * BUG: String.Left() sometimes fails. Print a warning if such a case is detected. --- .../.src/TerminalView/TerminalScreen.class | 17 +++++++++++++++-- 1 file changed, 15 insertions(+), 2 deletions(-) diff --git a/comp/src/gb.form.terminal/.src/TerminalView/TerminalScreen.class b/comp/src/gb.form.terminal/.src/TerminalView/TerminalScreen.class index 8d66a2070..fa7c43c40 100644 --- a/comp/src/gb.form.terminal/.src/TerminalView/TerminalScreen.class +++ b/comp/src/gb.form.terminal/.src/TerminalView/TerminalScreen.class @@ -205,15 +205,28 @@ Private Sub Insert(sText As String, Optional X As Integer = $X) Dim hLine As CTerminalLine Dim iLen As Integer = String.Len(sText) + Dim sLeft As String If iLen = 0 Then Return - 'Debug Quote(sText);; X;; $Y + 'Debug Quote(sText);; $Y;; iLen;; X;; $W If (X + iLen) > $W Then + If X >= $W Then + If Not WrapMode Then Return + Index() + $X = 0 + Insert(sText) + Return + Endif iLen = Max(0, $W - X) If iLen Then - Insert(String.Left(sText, iLen), X) + sLeft = String.Left(sText, iLen) + If String.Len(sLeft) <> iLen Then + Error "gb.form.terminal: warning: String.Left() failed: "; String.Len(sLeft);; iLen + Return + Endif + Insert(sLeft, X) sText = String.Mid$(sText, iLen + 1) Endif If WrapMode Then