Skip to content

Fixes #28. Fixes Alt+Enter. #29

New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
28 changes: 17 additions & 11 deletions lua/cheatsheet/telescope/actions.lua
Original file line number Diff line number Diff line change
Expand Up @@ -11,22 +11,28 @@ local function select_current_item(prompt_bufnr, execute)

t_actions.close(prompt_bufnr)

if string.len(cheat) == 1 then
if string.len(cheat) == 0 then
print("Cheatsheet: No command could be executed")
return
end

-- Extract command from cheat, eg:
-- ":%bdelete" -> No change
-- ":set hls!" -> No change
-- ":edit [file]" -> ":edit "
-- ":set shiftwidth={n}" -> ":set shiftwidth="
local command = cheat:match("^:[^%[%{]+")
if command ~= nil then
if execute then
vim.api.nvim_command(cheat)
if execute then
if cheat:find(":") then
-- Extract command from cheat, eg:
-- ":%bdelete" -> No change
-- ":set hls!" -> No change
-- ":edit [file]" -> ":edit "
-- ":set shiftwidth={n}" -> ":set shiftwidth="
local command = cheat:match("^:[^%[%{]+")
if command == cheat then
vim.api.nvim_command(cheat)
else
vim.api.nvim_feedkeys(command, "n", true)
end
else
vim.api.nvim_feedkeys(command, "n", true)
vim.api.nvim_feedkeys(
vim.api.nvim_replace_termcodes(cheat, true, true, true)
, "x", false)
end
else
vim.api.nvim_echo(
Expand Down