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

post_open shall provide bufnr and winnr for newly opened file #48

Closed
ragu-manjegowda opened this issue Apr 24, 2023 · 4 comments · Fixed by #55
Closed

post_open shall provide bufnr and winnr for newly opened file #48

ragu-manjegowda opened this issue Apr 24, 2023 · 4 comments · Fixed by #55
Assignees
Labels
bug Something isn't working

Comments

@ragu-manjegowda
Copy link

Describe the bug
If we want to do something in the call back that moves the focus to different tab, it is not possible to shift the focus back to newly opened tab.

To Reproduce
Steps to reproduce the behavior:

config

-- Setup toggle terminal

local ftzsh = fterm:new({
    ft = 'fterm_zsh',
    cmd = "zsh",
    dimensions = {
        height = 0.9,
        width = 0.9
    }
})

function M.__fterm_zsh()
    ftzsh:toggle()
end

-- Hide the terminal before jumping to new tab so that it opens in current tab next time.

{
    callbacks = {
        post_open = function(_, winnr, _, _)
            require("fterm").__fterm_zsh()  <-------- this moves the focus to current window where floating terminal is currently open
            vim.api.nvim_set_current_win(winnr)    <---------- need winnr of newly opened file here
        end
    },
    window = {
        open = "tab"
    }
}

With toggle terminal (fterm)

Open a file

Expected behavior
Focus should be on newly opened file

Screenshots
n/a

Desktop (please complete the following information):

  • Linux (Arch, Ubuntu)
  • 0.9

Additional context
It helps users to provide both current and new win/buf numbers to customize based on the use case. Let me know if you need more information or context.

@ragu-manjegowda ragu-manjegowda added the bug Something isn't working label Apr 24, 2023
@willothy
Copy link
Owner

Thanks for reporting, I'll look into this soon!

@willothy
Copy link
Owner

willothy commented Jun 28, 2023

Sorry for taking so long on this - to be clear, you want the window number of the terminal to be passed as well? I'm a bit unclear on the use case here as I don't really use tabs.

@ragu-manjegowda
Copy link
Author

ragu-manjegowda commented Jul 7, 2023

you want the window number of the terminal to be passed as well

If you can provide that why not? However, what I was looking for is window number of the newly opened file.

Lets say I have a tab with file A currently focused and I try to open file B in new tab from floating terminal, in post_open hook I would like to see the window number of the tab with file B.

@willothy
Copy link
Owner

It turns out this was what we were supposed to be doing the whole time, and this was definitely a bug. That's why I was initially confused. Will be fixed shortly.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

Successfully merging a pull request may close this issue.

2 participants