From a76d52433cd316a9989afccf10813f9d9221ea3b Mon Sep 17 00:00:00 2001
From: Benjamin Chausse <benjamin.chausse@goto.com>
Date: Thu, 3 Apr 2025 00:23:29 -0400
Subject: Better search + Aligned columns

---
 lua/dropship.lua | 15 +++++++++++++--
 1 file changed, 13 insertions(+), 2 deletions(-)

diff --git a/lua/dropship.lua b/lua/dropship.lua
index 7b5eb40..ca25eff 100644
--- a/lua/dropship.lua
+++ b/lua/dropship.lua
@@ -27,6 +27,13 @@ end
 
 local function get_target(opts, callback)
   opts = opts or {}
+
+  -- Calculate the maximum length from all entry names
+  local max_name_length = 0
+  for _, entry in ipairs(opts.drop_locations or M.drop_locations) do
+    max_name_length = math.max(max_name_length, #(entry.name or "Unknown"))
+  end
+
   pickers
     .new(opts, {
       prompt_title = opts.prompt_title or "Drop into which project?",
@@ -34,10 +41,14 @@ local function get_target(opts, callback)
       finder = finders.new_table({
         results = opts.drop_locations or M.drop_locations,
         entry_maker = function(entry)
+          local name = entry.name or "Unknown"
+          local dir = entry.dir or "Unknown"
+          local padded_name = name .. ":" .. string.rep(" ", max_name_length - #name + 1)
+          local display = padded_name .. dir
           return {
             value = entry,
-            display = (entry.name or "Unknown") .. ": " .. (entry.dir or "Unknown"),
-            ordinal = entry.name or ".",
+            display = display,
+            ordinal = display,
           }
         end,
       }),
-- 
cgit v1.2.3