diff options
-rw-r--r-- | src/files_map-editor.adb | 3 | ||||
-rw-r--r-- | src/files_map.adb | 2 | ||||
-rw-r--r-- | src/files_map.ads | 2 |
3 files changed, 5 insertions, 2 deletions
diff --git a/src/files_map-editor.adb b/src/files_map-editor.adb index ad04973dc..fb5721a47 100644 --- a/src/files_map-editor.adb +++ b/src/files_map-editor.adb @@ -393,6 +393,7 @@ package body Files_Map.Editor is Buf_Len : constant Source_Ptr := Get_Buffer_Length (File); begin if Text_Len + 2 > Buf_Len then + -- Buffer is too small! raise Constraint_Error; end if; @@ -401,6 +402,8 @@ package body Files_Map.Editor is Text_Ptr (Source_Ptr_Org .. Source_Ptr_Org + Text_Len - 1); end if; Set_File_Length (File, Text_Len); + + -- Move the gap after the two terminal EOT. Set_Gap (File, Text_Len + 2, Buf_Len - 1); -- Clear cache. diff --git a/src/files_map.adb b/src/files_map.adb index 1f316b879..24917592c 100644 --- a/src/files_map.adb +++ b/src/files_map.adb @@ -909,7 +909,7 @@ package body Files_Map is pragma Assert (File <= Source_Files.Last); F : Source_File_Record renames Source_Files.Table (File); begin - return Source_Ptr (F.Last_Location - F.First_Location - 1); + return Source_Ptr (F.Last_Location - F.First_Location + 1); end Get_Buffer_Length; -- Return the name of the file. diff --git a/src/files_map.ads b/src/files_map.ads index 41e37751e..a72c75d07 100644 --- a/src/files_map.ads +++ b/src/files_map.ads @@ -108,7 +108,7 @@ package Files_Map is procedure Set_File_Length (File : Source_File_Entry; Length : Source_Ptr); function Get_File_Length (File : Source_File_Entry) return Source_Ptr; - -- Get the length of the buffer, which includes the gap, but not the + -- Get the length of the buffer, which includes the gap and the -- two terminal EOT. function Get_Buffer_Length (File : Source_File_Entry) return Source_Ptr; |