Fix logic in project's file insertion

The function "file_search" in core.init was sometimes giving a wrong index
value, off by one.

The problem happened for example when the entry to search was "less than"
the first entry, the function returned a value of two instead of one as
expected.

The bug was easily observed creating a new directory with a name that comes
as the first in alphabetical order within the project.
This commit is contained in:
Francesco Abbate 2021-11-26 13:45:13 +01:00 committed by Guldoman
parent b918f248cb
commit 5f215ccbd4
No known key found for this signature in database
GPG Key ID: C08A498EC7F1AFDD
1 changed files with 2 additions and 2 deletions

View File

@ -199,12 +199,12 @@ local function file_search(files, info)
inf = curr
end
end
repeat
while inf <= sup and not system.path_compare(filename, type, files[inf].filename, files[inf].type) do
if files[inf].filename == filename then
return inf, true
end
inf = inf + 1
until inf > sup or system.path_compare(filename, type, files[inf].filename, files[inf].type)
end
return inf, false
end