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

feat(terminal): add mechanism to fetch last focused terminal #411

Merged
merged 2 commits into from
Mar 12, 2023

Conversation

akinsho
Copy link
Owner

@akinsho akinsho commented Mar 11, 2023

This is useful for plugins like flatten.nvim where you (really I) want to be able to check if the last toggled terminal was a float and if not not bother re-opening it e.g.

  callbacks = {
    pre_open = function() require('toggleterm').toggle() end,
    post_open = function(_, winnr)
      local term = require('toggleterm.terminal').get_last_focused() -- <--- Here
      if not term or not term:is_float() then term:toggle() end
      api.nvim_set_current_win(winnr)
    end,
    block_end = function() require('toggleterm').toggle() end,
  },

@akinsho akinsho force-pushed the feat/get-last-toggled-term branch from dcdda69 to c926ae0 Compare March 11, 2023 15:25
@akinsho akinsho merged commit bfb7a72 into main Mar 12, 2023
@akinsho akinsho deleted the feat/get-last-toggled-term branch March 12, 2023 09:57
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

1 participant