-
Notifications
You must be signed in to change notification settings - Fork 11
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
Bug: Preview show "[Process exited 0]" when delta is used #32
Comments
Your EDIT is entirely correct, nothing I can do about this message from my end 🙃 |
I came across this issue. Is there a solution for it? |
Is there any fix for this? |
Hi, there is no "fix" for this. Feel free to read up on it at the issue created by OP, which concerns the API I am using. As far as I can tell that issue only contains hacky fixes which involve stripping the last line or similar. I am not willing to implement those just for aesthetics, others might consider the line useful: It is proof that delta ran successfully and no lingering terminal is running in the background. Further, this message actually comes from the underlying Feel free to create an issue with Telescope, as anything I could do would basically patch their API response anyhow. If they respond similarly, you could decide to take it up in a Neovim issue. However, I hardly think they'll consider it: This would be a breaking change for plugins and scripts which might depend on that line being there. |
Thanks I read that but how would I use the workaround for just undo-telescope? |
I haven't tried it myself, but you would do the same as the commenters there: Set the previewer in the opts and Telescope should pick it up correctly. You can copy the previewer used by telescope-undo as a base and implement their changes on top or go for theirs entirely at first 👍🏻 |
Thanks I used yours as a base then merged it in, this seems to work: local function open_undo_ts()
local previewers = require("telescope.previewers")
local function get_previewer(opts)
if opts.use_custom_command ~= nil then
return previewers.new_termopen_previewer({
get_command = function(entry)
local difftext = entry.value.diff:gsub("'", [['"'"']])
return vim.tbl_map(function(part)
return part:gsub("$DIFF", difftext)
end, opts.use_custom_command)
end,
})
end
local has_powershell = vim.fn.executable("powershell") == 1
local has_bash = vim.fn.executable("bash") == 1
if
opts.use_delta
and not _G.__os.is_wsl
and (has_powershell or has_bash)
and vim.fn.executable("delta") == 1
then
return previewers.new_termopen_previewer({
get_command = function(entry)
local append = opts.side_by_side and " -s" or ""
if has_powershell then
return {
"powershell",
"-Command",
"echo '" .. entry.value.diff:gsub([[']], [['']]) .. "' | delta" .. append,
}
elseif has_bash then
return {
"bash",
"-c",
"echo '" .. entry.value.diff:gsub("'", [['"'"']]) .. "' | delta" .. append,
}
end
end,
})
else
-- Original undo previewer
-- return previewers.new_buffer_previewer({
-- define_preview = function(self, entry)
-- vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, true, vim.split(entry.value.diff, "\n"))
-- require("telescope.previewers.utils").highlighter(
-- self.state.bufnr,
-- "diff",
-- { preview = { treesitter = { enable = {} } } }
-- )
-- end,
-- })
return previewers.new_buffer_previewer({
define_preview = function(self, entry, status)
local dir_name = vim.fn.substitute(vim.fn.getcwd(), "^.*/", "", "")
local t = {}
if entry.value == dir_name then
local s = vim.fn.system("git status -s")
for chunk in string.gmatch(s, "[^\n]+") do
t[#t + 1] = chunk
end
else
local s = vim.fn.system("git -C " .. entry.value .. " status -s")
for chunk in string.gmatch(s, "[^\n]+") do
t[#t + 1] = chunk
end
end
vim.api.nvim_buf_set_lines(self.state.bufnr, 0, -1, true, t)
end,
})
end
end
require("telescope").extensions.undo.undo({
get_previewer = get_previewer,
})
end
vim.api.nvim_create_user_command("TelescopeUndo", open_undo_ts, {})
|
On linux
![screenshot_2023-06-05_02-39-30_650523552](https://private-user-images.githubusercontent.com/3357792/243228000-67baf763-a239-4e78-b548-a5763a345467.png?jwt=eyJhbGciOiJIUzI1NiIsInR5cCI6IkpXVCJ9.eyJpc3MiOiJnaXRodWIuY29tIiwiYXVkIjoicmF3LmdpdGh1YnVzZXJjb250ZW50LmNvbSIsImtleSI6ImtleTUiLCJleHAiOjE3MjQ0NDUxNzQsIm5iZiI6MTcyNDQ0NDg3NCwicGF0aCI6Ii8zMzU3NzkyLzI0MzIyODAwMC02N2JhZjc2My1hMjM5LTRlNzgtYjU0OC1hNTc2M2EzNDU0NjcucG5nP1gtQW16LUFsZ29yaXRobT1BV1M0LUhNQUMtU0hBMjU2JlgtQW16LUNyZWRlbnRpYWw9QUtJQVZDT0RZTFNBNTNQUUs0WkElMkYyMDI0MDgyMyUyRnVzLWVhc3QtMSUyRnMzJTJGYXdzNF9yZXF1ZXN0JlgtQW16LURhdGU9MjAyNDA4MjNUMjAyNzU0WiZYLUFtei1FeHBpcmVzPTMwMCZYLUFtei1TaWduYXR1cmU9MmZlMTA3ZDkzZDZhNmZkZjZhNDc2ODBjZTc5MTY3MTQ4ZGVhZDQyZThmNGJkZDkzNDM5MmZmMjlkNDhjZTdiOSZYLUFtei1TaWduZWRIZWFkZXJzPWhvc3QmYWN0b3JfaWQ9MCZrZXlfaWQ9MCZyZXBvX2lkPTAifQ.fZEogl4Evu3MTy8XFMzhB5Leilird3OSiRKVFOrEBFg)
EDIT: I see
previewers.new_termopen_previewer
is a Telescope method, so I should probably report it there.The text was updated successfully, but these errors were encountered: