lace.text.cursor: Fix bug in the 'peek' function.

This commit is contained in:
Rod Kay
2022-09-29 17:55:37 +10:00
parent 3fd3c580eb
commit 4675fa37c8

View File

@@ -141,14 +141,14 @@ is
end if;
declare
function get_String return String
is
use ada.Strings.fixed,
ada.Strings.Maps.Constants;
delimiter_Position : constant Natural := (if match_Case then Index (Self.Target.Data (Self.Current .. Self.Target.Length), Delimiter, from => Self.Current)
else Index (Self.Target.Data (Self.Current .. Self.Target.Length), to_Lower (Delimiter), from => Self.Current,
mapping => lower_case_Map));
begin
-- put_Line ("delimiter_Position" & delimiter_Position'Image);
if delimiter_Position = 0
then
return the_Token : constant String := (if Trim then fixed.Trim (Self.Target.Data (Self.Current .. Self.Target.Length), Both)
@@ -163,6 +163,14 @@ is
do
Self.Current := delimiter_Position + Delimiter'Length;
end return;
end get_String;
unslid_String : constant String := get_String;
slid_String : constant String (1 .. unslid_String'Length) := unslid_String;
begin
return slid_String;
end;
end next_Token;
@@ -258,6 +266,7 @@ is
end get_Real;
function Length (Self : in Item) return Natural
is
begin
@@ -268,7 +277,7 @@ is
function peek (Self : in Item; Length : in Natural := Remaining) return String
is
Last : constant Natural := (if Length = Natural'Last then Self.Target.Length
Last : Natural := (if Length = Remaining then Self.Target.Length
else Self.Current + Length - 1);
begin
if at_End (Self)
@@ -276,6 +285,9 @@ is
return "";
end if;
Last := Natural'Min (Last,
Self.Target.Length);
return Self.Target.Data (Self.Current .. Last);
end peek;