From 1cf29b2ed1a680126f6badec36c7166051958f31 Mon Sep 17 00:00:00 2001 From: Vadim Godunko Date: Wed, 13 Nov 2024 17:43:20 +0400 Subject: [PATCH] Don't move cursor forward when it points after last character. --- .../vss-implementation-text_handlers-utf8-dynamic.adb | 4 +++- .../vss-implementation-text_handlers-utf8-static.adb | 4 +++- 2 files changed, 6 insertions(+), 2 deletions(-) diff --git a/source/text/implementation/vss-implementation-text_handlers-utf8-dynamic.adb b/source/text/implementation/vss-implementation-text_handlers-utf8-dynamic.adb index 5f71b3f7..06f61adb 100644 --- a/source/text/implementation/vss-implementation-text_handlers-utf8-dynamic.adb +++ b/source/text/implementation/vss-implementation-text_handlers-utf8-dynamic.adb @@ -576,7 +576,9 @@ package body VSS.Implementation.Text_Handlers.UTF8.Dynamic is return; end if; - Unchecked_Forward (Self.Pointer.Storage, After); + if To.Index <= Self.Length then + Unchecked_Forward (Self.Pointer.Storage, After); + end if; Size := After.UTF8_Offset - From.UTF8_Offset; Length := After.Index - From.Index; diff --git a/source/text/implementation/vss-implementation-text_handlers-utf8-static.adb b/source/text/implementation/vss-implementation-text_handlers-utf8-static.adb index 58f6664e..1e4a5e83 100644 --- a/source/text/implementation/vss-implementation-text_handlers-utf8-static.adb +++ b/source/text/implementation/vss-implementation-text_handlers-utf8-static.adb @@ -515,7 +515,9 @@ package body VSS.Implementation.Text_Handlers.UTF8.Static is return; end if; - Unchecked_Forward (Self.Storage, After); + if To.Index <= Self.Length then + Unchecked_Forward (Self.Storage, After); + end if; Size := After.UTF8_Offset - From.UTF8_Offset; Length := After.Index - From.Index;