lewis6991 / gitsigns.nvim

Git integration for buffers
MIT License
5.22k stars 191 forks source link

Bindings only work in the first tab when using multiple tabs #266

Closed igorlfs closed 3 years ago

igorlfs commented 3 years ago

Describe the bug Bindings only work in the first tab when using multiple tabs.

To Reproduce

init.vim:

" I save my plugins in this directory, yours might be different
let $PLUGIN_DIRECTORY = '~/.local/share/nvim/site/autoload/plugged'
set runtimepath^=$PLUGIN_DIRECTORY/plenary.nvim
set runtimepath^=$PLUGIN_DIRECTORY/gitsigns.nvim

lua << EOF
require('gitsigns').setup {
  debug_mode = true, -- You must add this to enable debug messages
  -- config
}
EOF

Steps to reproduce the behavior:

  1. Create a temporary directory and initialize a repo
  2. Create 2 files: file_a and file_b
  3. Run $ vim -p file_a file_b
  4. Go to file_b's tab and insert some text
  5. Try to stage the hunk by doing <leader>hs. It won't work.

Observed output I think there's no relevant log, as it's just a matter of mappings

Additional context System: Void Linux Neovim version: 0.5

kitallen23 commented 3 years ago

I'm having a very similar issue, but it's to do with windows instead of tabs.

I have a simple binding:

['n <leader>gs'] = '<cmd>lua require"gitsigns".stage_hunk()<CR>',

I have tried this with both buffer = true and buffer = false.

I use sessions (prosession) to keep my windows and buffers open on exit. So when I launch vim in my project, I have n buffers open, and two windows (a vsplit).

Let's call my two open buffers Buffer A and Buffer B

In the first window that the cursor is in (Buffer A), the binding works fine. If I change the buffer in that same window (Buffer B), the binding fails to work. If I change windows and try in either buffer, the binding fails to work.

So the binding only works in the first buffer in the first window.

To add to the strangeness, if I close my second window (so I only have a single window open when I start nvim), the binding works fine in both Buffer A and Buffer B.

lewis6991 commented 3 years ago

Thanks guys for the info.

This was pretty easy to debug and fix. Basically, the mappings weren't being applied to buffers that were being opened in the background. Suprised no one has raised this issue earlier.

lewis6991 commented 3 years ago

Should be fixed. Let me know if the issue persists.