Open keaising opened 1 year ago
I can reproduce this.
I dug around a little bit while I don't really have a solution, my instinct is telling me that that command is not very well suited for passing the output through pipes. At least not with how telescope currently works.
I played around with this bit of code. If you do as well, you should see that, for you command, after the first stdout chunk, each subsequent chunk appears to start with a new line. The telescope code doesn't handle that well. Try it with the original command, the new line comes after the chunk is done. Maybe the telescope code should handle this better, but also maybe git is being weird.
Thanks for your instinct, I find a workround to solve this issue.
I create a bash script named gitlog.sh
to output all content of git log
in one time, so the content passed to Telescope will be processed only once, it works as my wish!
This is my script:
#!/usr/bin/env bash
# $1 is the file path from Telescope
git log --date="format:%y/%m/%d" --pretty="format:%C(auto) %h %ad %s" --follow $1 >/tmp/gitlog && cat /tmp/gitlog
And this is my Telescope config
config = function()
local bufopts = { noremap = true, silent = true }
local builtin = require("telescope.builtin")
vim.keymap.set("n", "gb", function()
builtin.git_bcommits({
git_command = { "/location/of/gitlog.sh" },
})
end, bufopts)
vim.keymap.set("n", "gj", builtin.git_bcommits, bufopts)
require("telescope").setup({})
end,
@jamestrew Do you think it's necessary to keep this issue open and let's work through it to solve the problem once and for all, or do we just stop here, there's already a workround anyway, after all not all bugs have to be fixed and it's not necessarily a Telescope's bug
I think it's ok to leave it open. This might be something worth looking into deeper.
Thanks for your instinct, I find a workround to solve this issue.
I create a bash script named
gitlog.sh
to output all content ofgit log
in one time, so the content passed to Telescope will be processed only once, it works as my wish!This is my script:
#!/usr/bin/env bash # $1 is the file path from Telescope git log --date="format:%y/%m/%d" --pretty="format:%C(auto) %h %ad %s" --follow $1 >/tmp/gitlog && cat /tmp/gitlog
And this is my Telescope config
config = function() local bufopts = { noremap = true, silent = true } local builtin = require("telescope.builtin") vim.keymap.set("n", "gb", function() builtin.git_bcommits({ git_command = { "/location/of/gitlog.sh" }, }) end, bufopts) vim.keymap.set("n", "gj", builtin.git_bcommits, bufopts) require("telescope").setup({}) end,
I tried your workaound, but I still get an empty window. However if I replace what’s inside of the gitlog.sh
file with
git log --follow $1 >/tmp/gitlog && cat /tmp/gitlog
then I do get the result of git log in my telescope popup …
EDIT: If I just add an echo "" >> /tmp/gitlog
command in the end it works
¯\_(ツ)_/¯
So the workaround becomes
git log --date="format:%y/%m/%d" --pretty="format:%C(auto) %h %ad %s" --follow $1 \
>/tmp/gitlog \
&& echo "" >> /tmp/gitlog \
&& cat /tmp/gitlog
Description
In my use case, I use customized
git_command
ingit_bcommits
, and meet errorBut if I use default command, it's ok
My customized command:
Default command in Telescope
I think maybe my customized command missed something needed, but I can not find the difference between the results of these two command
PS. This issue can be reliably reproduced only on some files. If you cannot reproduce it in your projects or files, please try this file https://github.com/keaising/dotfile/blob/master/nvim/.config/nvim/lua/plugins/telescope.lua , the issue can be reliably reproduced on it.
Neovim version
Operating system and version
ArchLinux, latest
Telescope version / branch / rev
master branch
checkhealth telescope
Steps to reproduce
git clone git@github.com:keaising/dotfile.git
minimal.lua
content intominimal.lua
in dotfile foldernvim -u minimal.lua nvim/.config/nvim/lua/plugins/telescope.lua
lazy
install all plugins neededgb
can meet the errorgj
will not meet the errorExpected behavior
No error
Actual behavior
Minimal config