aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorFrancesco Abbate <francesco.bbt@gmail.com>2022-01-05 23:21:47 +0100
committerFrancesco Abbate <francesco.bbt@gmail.com>2022-01-05 23:21:47 +0100
commit9929ca9c2d83231872a2b5fb05f4c27f41d092c0 (patch)
tree4dc696f33a5f4922c3cdc0a1b87fb549b45bc182
parentf3cf7ac9c7d60a9d23f031ab526d0a279c2fa410 (diff)
downloadlite-xl-9929ca9c2d83231872a2b5fb05f4c27f41d092c0.tar.gz
lite-xl-9929ca9c2d83231872a2b5fb05f4c27f41d092c0.zip
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.
-rw-r--r--data/core/commands/core.lua9
1 files 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)