camgraff / telescope-tmux.nvim

Integration for tmux with telescope.nvim
123 stars 5 forks source link

Tmux window previewer shows blank content for all windows #2

Open akinsho opened 3 years ago

akinsho commented 3 years ago

Hi,

Thanks for making this, it's pretty handy for tmux users 👍🏿 One issue I've not been able to figure out is that whilst using the window previewer it doesn't actually show the content of my windows. So I can't tell which one I want to actually jump to

image

akinsho commented 3 years ago

Lemme know if you need more info, I'm not sure what might be useful

camgraff commented 3 years ago

I think it's a bug with duplicate window names in the same session. Will try to fix it in the next couple of days.

akinsho commented 3 years ago

~@camgraff it's probably because I have an autocommand in nvim to auto rename the window on focus gained and focus lost, so when not in focus they all have the same name 🤔😅~

EDIT: That's actually not true I just set the window name to the terminal title in my tmux config and set the terminal title to the current file in neovim

camgraff commented 3 years ago

I just pushed some changes. Let me know if you're still having issues

akinsho commented 3 years ago

@camgraff it still seems to behave the same

image

image

maybe the window number is a more unique identifier, tbh I thought the status format would alter the name, just discovering that it doesn't

camgraff commented 3 years ago

You ran :PlugUpdate or :PackerUpdate and :PackerCompile if you're using packer?

If yes, I want to get clarification. The issue is the when you cycle through the entries in the "Results" window, the preview window continues to show the .dotfiles directory which is not the actual contents of the tmux window you are hovered over?

Also, what version of tmux are you using?

camgraff commented 3 years ago

maybe the window number is a more unique identifier, tbh I thought the status format would alter the name, just discovering that it doesn't

Under the hood, it uses the session name + window id to determine which window to preview which should be unambiguous. I'll also add an option for passing a custom format string which will let you incorporate the status format in the picker entry display

akinsho commented 3 years ago

@camgraff I've definitely updated, and I'm on tmux version 3.0a on Ubuntu 20.04. The thing in the screenshot that seems odd from the preview is that the tmux statusline in the example shows telescope tmux previewer as the session name, and it doesn't highlight correctly whereas the session previewer works correctly (note I had to set the TERM variable in telescope to get that working for sessions)

akinsho commented 3 years ago

Another weird thing is that it says there are 7 results which is correct but the number of results in the results' pane is not correct it shows only 6 results in the screenshot (and locally)

camgraff commented 3 years ago

shows telescope tmux previewer as the session name

This is because the extension creates a "dummy session" named telescope-tmux-previewer and links the tmux window to the dummy session in order to display the preview.

doesn't highlight correctly

Can you post side by side screenshots of your tmux window normally and inside the telescope previewer to illustrate this?

Another weird thing is that it says there are 7 results which is correct but the number of results in the results' pane is not correct it shows only 6 results in the screenshot (and locally)

The extra result is the session/window you are currently in when invoking the extension. I'll fix this.

akinsho commented 3 years ago

The highlighting issue is resolved for the session previewer just to be clear, I found a solution i.e. adding the terminal env variable in the telescope setup. i.e.

  telescope.setup {
    defaults = {
      set_env = { ['TERM'] = vim.env.TERM },
    }
   }

With the solution

image

Without the solution

image

I only mentioned it since the statusline in the previewer for the windows appears to also show a brown statusline rather than dark blue, which is expected.

In windows previewer

image

In regular tmux

image

Just to be clear this seems like a different issue from the windows not being previewed, I only mentioned just in case it provides any clues

camgraff commented 3 years ago

Ok, I'm still trying to understand your issue with the window previewer. So you do not have the same behavior that is shown in the gif below?

akinsho commented 3 years ago

Nope, that looks great. On my end it just shows an empty tmux window in the preview pane. I'll try to send you a gif when next I'm at my computer

akinsho commented 3 years ago

@camgraff here's a GIF of what it looks like on my machine

tmux-telescope-bug

Unlike your GIF it doesn't actually show me the contents of my various tmux windows.

camgraff commented 3 years ago

Okay, hopefully it's fixed now. I noticed in your gif/screenshots that your previewer has 2 windows instead of just 1. I'm guessing you're setting base-index in your .tmux.conf to 1? This was resulting in the previewer showing the window at index 1 instead of 0. I changed this to take into account the base-index option. Changes are up, let me know if the issue persists.

akinsho commented 3 years ago

@camgraff that did it, it now shows the proper previews 🎉

image

Thanks for sticking with this 👍🏿 , one last question 😅 , passing the env variable fixed the highlighting for my sessions' previewer, but the same fix doesn't work for my windows' previewer, not sure how it works under the hood, but maybe it isn't taking the TERM env variable I'm passing into consideration.

camgraff commented 3 years ago

I'll look into the highlighting issue, but might take a bit. Busy lately 🙂

akinsho commented 3 years ago

@camgraff I've dug into this a little and I think the reason might be that In the session previewer you use the telescope termopen previewer https://github.com/camgraff/telescope-tmux.nvim/blob/be1c06c396d302c7bb9046c4e90b8ed51bc3de86/lua/telescope/_extensions/tmux/sessions.lua#L69

Whereas in the window previewer you open a terminal job yourself. I think that the env of telescope is not passed to this job which is why the dummy session doesn't inherit my terminal variable.

https://github.com/camgraff/telescope-tmux.nvim/blob/be1c06c396d302c7bb9046c4e90b8ed51bc3de86/lua/telescope/_extensions/tmux/windows.lua#L60