From 10dbbfb98cee33b06ca19e936732309725d0fdf9 Mon Sep 17 00:00:00 2001 From: Tristan Gingold Date: Tue, 4 Feb 2020 18:58:10 +0100 Subject: files_map-editor: fix file_length when moving gap at end. --- src/files_map-editor.adb | 5 ++++- 1 file changed, 4 insertions(+), 1 deletion(-) diff --git a/src/files_map-editor.adb b/src/files_map-editor.adb index d339f3578..1cf5bd947 100644 --- a/src/files_map-editor.adb +++ b/src/files_map-editor.adb @@ -193,6 +193,8 @@ package body Files_Map.Editor is F.Source (New_Start .. New_Start + Diff - 1); if F.Gap_Start >= F.File_Length then + -- The gap was after the EOT. As it is moved before, we need + -- to increase the file length. F.File_Length := F.File_Length + Gap_Len; end if; @@ -213,7 +215,8 @@ package body Files_Map.Editor is F.Source (F.Gap_Start .. F.Gap_Start + Diff - 1) := F.Source (F.Gap_Last + 1 .. F.Gap_Last + 1 + Diff - 1); - if New_Start + Gap_Len >= F.File_Length then + if New_Start + Gap_Len > F.File_Length then + -- Moved past the end of file. Decrease the file length. F.File_Length := F.File_Length - Gap_Len; end if; -- cgit v1.2.3