From 0d36fc0cf826d73de2349c21307b7a4edc809246 Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Tue, 31 Oct 2023 12:59:51 +0700 Subject: [PATCH 1/2] fix(developer): enable line breaks in debugger Fixes #9444. --- developer/src/tike/child/UfrmDebug.pas | 9 ++++++++- 1 file changed, 8 insertions(+), 1 deletion(-) diff --git a/developer/src/tike/child/UfrmDebug.pas b/developer/src/tike/child/UfrmDebug.pas index 30c91eba0c3..a6aa3ad752f 100644 --- a/developer/src/tike/child/UfrmDebug.pas +++ b/developer/src/tike/child/UfrmDebug.pas @@ -759,10 +759,16 @@ TMemoSelectionState = record begin Assert(m >= 1); Assert(memo.Text[m] <> #$FFFC); + // Delete surrogate pairs if (m > 1) and Uni_IsSurrogate2(memo.Text[m]) and Uni_IsSurrogate1(memo.Text[m-1]) then Dec(m, 2) + // Delete \r\n line breaks + else if (m > 1) and + (memo.Text[m] = #$0A) and + (memo.Text[m-1] = #$0D) then + Dec(m, 2) else Dec(m); end; @@ -894,7 +900,8 @@ TMemoSelectionState = record state: TMemoSelectionState; begin state := SaveMemoSelectionState; - memo.SelText := Text; + // Line breaks: replace \n with \r\n so line breaks work + memo.SelText := ReplaceStr(Text, #$0D, #$0D#$0A); memo.SelStart := memo.SelStart + memo.SelLength; // I1603 memo.SelLength := 0; RealignMemoSelectionState(state); From e2ecf5726cec7405147a7a602bf7a9e9353fa89a Mon Sep 17 00:00:00 2001 From: Marc Durdin Date: Thu, 2 Nov 2023 14:17:49 +1100 Subject: [PATCH 2/2] chore: Apply suggestions from code review --- developer/src/tike/child/UfrmDebug.pas | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/developer/src/tike/child/UfrmDebug.pas b/developer/src/tike/child/UfrmDebug.pas index a6aa3ad752f..c6a04b45017 100644 --- a/developer/src/tike/child/UfrmDebug.pas +++ b/developer/src/tike/child/UfrmDebug.pas @@ -900,7 +900,7 @@ TMemoSelectionState = record state: TMemoSelectionState; begin state := SaveMemoSelectionState; - // Line breaks: replace \n with \r\n so line breaks work + // Line breaks: replace \r (0x0D) with \r\n (0x0D 0x0A) so line breaks work memo.SelText := ReplaceStr(Text, #$0D, #$0D#$0A); memo.SelStart := memo.SelStart + memo.SelLength; // I1603 memo.SelLength := 0;