From 5f215ccbd493d55df56d352084aef361b204ca5d Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Fri, 26 Nov 2021 13:45:13 +0100 Subject: [PATCH] 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. --- data/core/init.lua | 4 ++-- 1 file changed, 2 insertions(+), 2 deletions(-) diff --git a/data/core/init.lua b/data/core/init.lua index 62536ad9..2fa4454f 100644 --- a/data/core/init.lua +++ b/data/core/init.lua @@ -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