nvim-telescope / telescope.nvim

Find, Filter, Preview, Pick. All lua, all the time.
MIT License
15.45k stars 823 forks source link

[Windows][Powershell] Can't scroll preview when using git-delta in commits panel #2764

Open searleser97 opened 10 months ago

searleser97 commented 10 months ago

Description

<C-D> and <C-U> do not scroll when using git delta as previewer for commits in windows powershell

Neovim version

NVIM v0.10.0-dev-953+g1635c9e75
Build type: RelWithDebInfo
LuaJIT 2.1.1693019600

Operating system and version

Windows 11

Telescope version / branch / rev

master

checkhealth telescope

==============================================================================
telescope: require("telescope.health").check()

Checking for required plugins ~
- OK plenary installed.
- OK nvim-treesitter installed.

Checking external dependencies ~
- OK rg: found ripgrep 13.0.0 (rev af6b6c543b)
- OK fd: found fd 8.7.0

===== Installed extensions ===== ~

Telescope Extension: `file_browser` ~
- No healthcheck provided

Telescope Extension: `harpoon` ~
- No healthcheck provided

Telescope Extension: `live_grep_args` ~
- No healthcheck provided

Telescope Extension: `recent_files` ~
- No healthcheck provided

Steps to reproduce

  1. open git commits panel with gc based on the mapping listed below (minimal config section)
  2. observe that you can not scroll through the preview

Expected behavior

be able to scroll the preview with <c-d> and <c-u> when using git delta as pager

Actual behavior

<c-d> and <c-u> do not work when using git delta as pager

Minimal config

local telescope_builtin = require('telescope.builtin')
local previewers = require('telescope.previewers')

local delta_previewer = previewers.new_termopen_previewer {
  get_command = function(entry)
    return { 'git', '-c', 'core.pager=delta', '-c', 'delta.side-by-side=false', 'diff', entry.value .. '^!' }
  end
}
vim.keymap.set("n", "gc", function ()
  telescope_builtin.git_commits({
    previewer = delta_previewer
  })
end, { noremap = true, desc = "git branch commits" })
searleser97 commented 10 months ago

@tjdevries Could you point me in the right direction of how I could fix this ? I am open to contribute, but hard to know where to start

Thanks

jamestrew commented 10 months ago

Seems to be working fine on Linux. I'm not sure what's happening on Windows to cause this issue.

searleser97 commented 9 months ago

Looks like this is the line that is not working correctly for windows, any ideas ?

https://github.com/nvim-telescope/telescope.nvim/blob/6213322ab56eb27356fdc09a5078e41e3ea7f3bc/lua/telescope/previewers/term_previewer.lua#L228

searleser97 commented 9 months ago

Tested with ToggleTerm, and sending commands there work as expected on Windows (I can scroll delta pager by sending "10d" for example).

Looks like the same "chansend" command is used, probably we still have hope https://github.com/akinsho/toggleterm.nvim/blob/91be5f327e42aa016da13b277540de8dba0b14e3/lua/toggleterm/terminal.lua#L317-L328

searleser97 commented 9 months ago

Tested with ToggleTerm, and sending commands there work as expected on Windows (I can scroll delta pager by sending "10d" for example).

Looks like the same "chansend" command is used, probably we still have hope https://github.com/akinsho/toggleterm.nvim/blob/91be5f327e42aa016da13b277540de8dba0b14e3/lua/toggleterm/terminal.lua#L317-L328

I tried appending "\r" as in toggleterm but still not working :(

Any more ideas ? @jamestrew @tjdevries @henrik

jamestrew commented 9 months ago

Thanks @searleser97 for doing this digging.

Give me a few days to let me take a closer look.

searleser97 commented 9 months ago

Probably this scroll_bottom function is what makes the magic in toggleterm

https://github.com/akinsho/toggleterm.nvim/blob/91be5f327e42aa016da13b277540de8dba0b14e3/lua/toggleterm/terminal.lua#L321C23-L321C23

searleser97 commented 9 months ago

So, this is what worked for me:

image

image