From 9929ca9c2d83231872a2b5fb05f4c27f41d092c0 Mon Sep 17 00:00:00 2001 From: Francesco Abbate Date: Wed, 5 Jan 2022 23:21:47 +0100 Subject: [PATCH] Fix logic with project directories suggestions Attempt to fix issue #791. The logic set with the previous commit for suggest_directory is similar to the one we use except the previous expression was false do to operator precedence for "and" versus "or". With the modification here, when opening a project directory, we suggest the recently used projects if the text is equal to dirname(project_dir) + "/" which happens to be the text the command view is initially set to. In addition we do the same if text is "". If the condition is not met we return the suggestions from common.dir_path_suggest to match the text entered. Works well on Linux but may not solve the problem on Windows, it should be tested. --- data/core/commands/core.lua | 9 +++++---- 1 file changed, 5 insertions(+), 4 deletions(-) diff --git a/data/core/commands/core.lua b/data/core/commands/core.lua index 3242e2ef..29626c86 100644 --- a/data/core/commands/core.lua +++ b/data/core/commands/core.lua @@ -10,8 +10,9 @@ local restore_title_view = false local function suggest_directory(text) text = common.home_expand(text) - return common.home_encode_list((text == "" or text == common.home_expand(common.dirname(core.project_dir))) - and core.recent_projects or common.dir_path_suggest(text)) + local basedir = common.dirname(core.project_dir) + return common.home_encode_list((basedir and text == basedir .. PATHSEP or text == "") and + core.recent_projects or common.dir_path_suggest(text)) end command.add(nil, { @@ -149,7 +150,7 @@ command.add(nil, { ["core:change-project-folder"] = function() local dirname = common.dirname(core.project_dir) if dirname then - core.command_view:set_text(common.home_encode(dirname)) + core.command_view:set_text(common.home_encode(dirname) .. PATHSEP) end core.command_view:enter("Change Project Folder", function(text, item) text = system.absolute_path(common.home_expand(item and item.text or text)) @@ -169,7 +170,7 @@ command.add(nil, { ["core:open-project-folder"] = function() local dirname = common.dirname(core.project_dir) if dirname then - core.command_view:set_text(common.home_encode(dirname)) + core.command_view:set_text(common.home_encode(dirname) .. PATHSEP) end core.command_view:enter("Open Project", function(text, item) text = common.home_expand(item and item.text or text)