aboutsummaryrefslogtreecommitdiffstats
path: root/src
diff options
context:
space:
mode:
authorTristan Gingold <tgingold@free.fr>2020-02-04 18:58:10 +0100
committerTristan Gingold <tgingold@free.fr>2020-02-04 18:58:13 +0100
commit10dbbfb98cee33b06ca19e936732309725d0fdf9 (patch)
tree1ab118b7cafd0175f6093b1cf7ac1ecdc502f877 /src
parenta3c8e965181a81710d1da42a32e0efcd376df1bb (diff)
downloadghdl-10dbbfb98cee33b06ca19e936732309725d0fdf9.tar.gz
ghdl-10dbbfb98cee33b06ca19e936732309725d0fdf9.tar.bz2
ghdl-10dbbfb98cee33b06ca19e936732309725d0fdf9.zip
files_map-editor: fix file_length when moving gap at end.
Diffstat (limited to 'src')
-rw-r--r--src/files_map-editor.adb5
1 files changed, 4 insertions, 1 deletions
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;