From 093e07af7d15a603164aa77497e157b129e1baad Mon Sep 17 00:00:00 2001 From: ujisati <> Date: Sat, 18 May 2024 01:09:17 -0600 Subject: [PATCH] trim whitespace in subcommands --- lua/telekasten.lua | 7 ++++--- 1 file changed, 4 insertions(+), 3 deletions(-) diff --git a/lua/telekasten.lua b/lua/telekasten.lua index ce6fa93..b6d6eed 100644 --- a/lua/telekasten.lua +++ b/lua/telekasten.lua @@ -2945,6 +2945,7 @@ local TelekastenCmd = { end, } +---@param subcommand string TelekastenCmd.command = function(subcommand) local show = function(opts) opts = opts or {} @@ -2979,15 +2980,15 @@ TelekastenCmd.command = function(subcommand) :find() end if subcommand then - -- print("trying subcommand " .. "`" .. subcommand .. "`") + local trimmed_subcommand = string.gsub(subcommand, "^%s*(.-)%s*$", "%1") for _, entry in pairs(TelekastenCmd.commands()) do - if entry[2] == subcommand then + if entry[2] == trimmed_subcommand then local selection = entry[3] selection() return end end - print("No such subcommand: `" .. subcommand .. "`") + print("No such subcommand: `" .. trimmed_subcommand .. "`") else local theme