Skip to content

Commit

Permalink
Merge pull request #331 from ujisati/refact
Browse files Browse the repository at this point in the history
trim whitespace in subcommands
  • Loading branch information
lambtho12 authored May 22, 2024
2 parents 7b22b78 + 093e07a commit 981aacd
Showing 1 changed file with 4 additions and 3 deletions.
7 changes: 4 additions & 3 deletions lua/telekasten.lua
Original file line number Diff line number Diff line change
Expand Up @@ -2945,6 +2945,7 @@ local TelekastenCmd = {
end,
}

---@param subcommand string
TelekastenCmd.command = function(subcommand)
local show = function(opts)
opts = opts or {}
Expand Down Expand Up @@ -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

Expand Down

0 comments on commit 981aacd

Please sign in to comment.