From 7d0e85f00b09a93e5583447b21db50342b71eadb Mon Sep 17 00:00:00 2001 From: Steven Arcangeli Date: Fri, 3 Dec 2021 22:59:01 -0800 Subject: [PATCH] fix: format_item doesn't have to return a string This is perhaps ambiguous from the core docs, but format_item can return values that are not strings and they will then be stringified. So we should do the same --- lua/dressing/select/init.lua | 12 +++++++++++- 1 file changed, 11 insertions(+), 1 deletion(-) diff --git a/lua/dressing/select/init.lua b/lua/dressing/select/init.lua index 2eeb251..8210da7 100644 --- a/lua/dressing/select/init.lua +++ b/lua/dressing/select/init.lua @@ -28,7 +28,17 @@ return function(items, opts, on_choice) opts = opts or {} local config = global_config.get_mod_config("select", opts) opts.prompt = opts.prompt or "Select one of:" - opts.format_item = opts.format_item or tostring + if opts.format_item then + -- Make format_item doesn't *technically* have to return a string for the + -- core implementation. We should maintain compatibility by wrapping the + -- return value with tostring + local format_item = opts.format_item + opts.format_item = function(item) + return tostring(format_item(item)) + end + else + opts.format_item = tostring + end local backend, name = get_backend(config) backend.select(config[name], items, opts, on_choice)