Skip to content
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

fix scrolling not working in term previewers for windows #2810

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Show file tree
Hide file tree
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
3 changes: 2 additions & 1 deletion lua/telescope/previewers/term_previewer.lua
Original file line number Diff line number Diff line change
Expand Up @@ -225,7 +225,8 @@ previewers.new_termopen_previewer = function(opts)
return
end

vim.fn.chansend(term_id, termcode)
vim.fn.chansend(term_id, termcode .. (utils.is_windows() and "\r\n" or ""))
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

can you try this? the docs say when passing a list, we can include an final empty string to send a final newline. That might simplify things and remove the need to check for is_windows.

Suggested change
vim.fn.chansend(term_id, termcode .. (utils.is_windows() and "\r\n" or ""))
vim.fn.chansend(term_id, { termcode, "" })

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

If we do this, we will also affect unix-like systems with change, have you tested it preserves the same behavior on unix-like systems ? I will do the windows test next week

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Yeah my suggestion works on Linux. Just curious if it will on windows as well.

vim.api.nvim_buf_call(self.state.termopen_bufnr, function() vim.cmd("normal! G") end)
Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

you found that this was necessary on windows? just confirming.

Copy link
Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

yes, working like a charm in Windows 11

end
end
end
Expand Down
4 changes: 4 additions & 0 deletions lua/telescope/utils.lua
Original file line number Diff line number Diff line change
Expand Up @@ -15,6 +15,10 @@ local get_status = require("telescope.state").get_status

local utils = {}

utils.is_windows = function()
return package.config:sub(1,1) == "\\";
end

utils.get_separator = function()
return Path.path.sep
end
Expand Down