telescope.nvim icon indicating copy to clipboard operation
telescope.nvim copied to clipboard

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

Open searleser97 opened this issue 2 years ago • 9 comments

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 avatar Oct 31 '23 23:10 searleser97

@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

searleser97 avatar Nov 03 '23 00:11 searleser97

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

jamestrew avatar Nov 04 '23 20:11 jamestrew

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 avatar Dec 13 '23 22:12 searleser97

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 avatar Dec 14 '23 01:12 searleser97

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

searleser97 avatar Dec 14 '23 01:12 searleser97

Thanks @searleser97 for doing this digging.

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

jamestrew avatar Dec 14 '23 05:12 jamestrew

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 avatar Dec 14 '23 17:12 searleser97

So, this is what worked for me:

image

image

searleser97 avatar Dec 14 '23 17:12 searleser97