From 58a7ccfb0cbc54e4a2be5a0a86b3121abdc29085 Mon Sep 17 00:00:00 2001 From: Luca Naef Date: Wed, 10 Aug 2022 23:38:40 -0400 Subject: [PATCH 1/3] fix space --- lua/telescope/_extensions/zoxide/list.lua | 17 ++++++----------- 1 file changed, 6 insertions(+), 11 deletions(-) diff --git a/lua/telescope/_extensions/zoxide/list.lua b/lua/telescope/_extensions/zoxide/list.lua index 3390d27..cc18d12 100644 --- a/lua/telescope/_extensions/zoxide/list.lua +++ b/lua/telescope/_extensions/zoxide/list.lua @@ -60,20 +60,14 @@ local fuzzy_with_z_score_bias = function(opts) end local entry_maker = function(item) - local items = vim.split(string.gsub(item, '^%s*(.-)%s*$', '%1'), " ") - local score = 0 - local item_path = item - - if #items > 1 then - score = tonumber(items[1]) - item_path = items[2] - end + local trimmed = string.gsub(item, '^%s*(.-)%s*$', '%1') + local item_path = string.gsub(trimmed, '^[^%s]* (.*)$', '%1') + local score = string.gsub(trimmed, '^([^%s]*) .*$', '%1') return { - value = item, + value = item_path, ordinal = item_path, - display = item, - + display = item_path, z_score = score, path = item_path } @@ -82,6 +76,7 @@ end local create_mapping = function(prompt_bufnr, mapping_config) return function() local selection = action_state.get_selected_entry() + print("selection:", vim.inspect(selection)) if mapping_config.before_action ~= nil then mapping_config.before_action(selection) From b33850248110447cc849791e37599733afa367b9 Mon Sep 17 00:00:00 2001 From: Luca Naef Date: Thu, 11 Aug 2022 12:04:50 -0400 Subject: [PATCH 2/3] cast to bool --- lua/telescope/_extensions/zoxide/list.lua | 4 +--- 1 file changed, 1 insertion(+), 3 deletions(-) diff --git a/lua/telescope/_extensions/zoxide/list.lua b/lua/telescope/_extensions/zoxide/list.lua index cc18d12..c5adc10 100644 --- a/lua/telescope/_extensions/zoxide/list.lua +++ b/lua/telescope/_extensions/zoxide/list.lua @@ -62,7 +62,7 @@ end local entry_maker = function(item) local trimmed = string.gsub(item, '^%s*(.-)%s*$', '%1') local item_path = string.gsub(trimmed, '^[^%s]* (.*)$', '%1') - local score = string.gsub(trimmed, '^([^%s]*) .*$', '%1') + local score = tonumber(string.gsub(trimmed, '^([^%s]*) .*$', '%1')) return { value = item_path, @@ -76,8 +76,6 @@ end local create_mapping = function(prompt_bufnr, mapping_config) return function() local selection = action_state.get_selected_entry() - print("selection:", vim.inspect(selection)) - if mapping_config.before_action ~= nil then mapping_config.before_action(selection) end From 3d4a0c16a2c72e5a11255903fcd61295f83e05ba Mon Sep 17 00:00:00 2001 From: Luca Naef Date: Thu, 11 Aug 2022 12:35:39 -0400 Subject: [PATCH 3/3] fix tonumber --- lua/telescope/_extensions/zoxide/list.lua | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) diff --git a/lua/telescope/_extensions/zoxide/list.lua b/lua/telescope/_extensions/zoxide/list.lua index c5adc10..93d1c5c 100644 --- a/lua/telescope/_extensions/zoxide/list.lua +++ b/lua/telescope/_extensions/zoxide/list.lua @@ -62,7 +62,7 @@ end local entry_maker = function(item) local trimmed = string.gsub(item, '^%s*(.-)%s*$', '%1') local item_path = string.gsub(trimmed, '^[^%s]* (.*)$', '%1') - local score = tonumber(string.gsub(trimmed, '^([^%s]*) .*$', '%1')) + local score = tonumber(string.gsub(trimmed, '^([^%s]*) .*$', '%1'), 10) return { value = item_path,