From 497e6f45fbfdc92dd0fec44e8ed3fb5391f307e7 Mon Sep 17 00:00:00 2001 From: Chris Grieser <73286100+chrisgrieser@users.noreply.github.com> Date: Sat, 10 Feb 2024 20:29:57 +0100 Subject: [PATCH] improv(moveToFolderInCwd): initially sort by mtime --- lua/genghis/init.lua | 7 +++++++ 1 file changed, 7 insertions(+) diff --git a/lua/genghis/init.lua b/lua/genghis/init.lua index 3cf91f2..094a533 100644 --- a/lua/genghis/init.lua +++ b/lua/genghis/init.lua @@ -138,6 +138,13 @@ function M.moveToFolderInCwd() return not ignoreDirs end, { type = "directory", limit = math.huge }) + -- sort by modification time + table.sort(subfoldersOfCwd, function(a, b) + local aMtime = vim.loop.fs_stat(a).mtime.sec + local bMtime = vim.loop.fs_stat(b).mtime.sec + return aMtime > bMtime + end) + -- prompt user and move local promptStr = "Choose Destination Folder" if supportsImportUpdates then promptStr = promptStr .. " (with updated imports)" end