mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 09:44:31 +00:00 
			
		
		
		
	fix(treesitter): close InspectTree/EditQuery window on BufUnload (#31036)
Problem:  The window opened :InspectTree or :EditQuery isn't closed when
          the source buffer is unloaded, even though it is closed when
          the buffer is hidden.
Solution: Also close the window on BufUnload.
			
			
This commit is contained in:
		@@ -527,7 +527,7 @@ function M.inspect_tree(opts)
 | 
				
			|||||||
    end,
 | 
					    end,
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  api.nvim_create_autocmd('BufHidden', {
 | 
					  api.nvim_create_autocmd({ 'BufHidden', 'BufUnload' }, {
 | 
				
			||||||
    group = group,
 | 
					    group = group,
 | 
				
			||||||
    buffer = buf,
 | 
					    buffer = buf,
 | 
				
			||||||
    once = true,
 | 
					    once = true,
 | 
				
			||||||
@@ -665,10 +665,10 @@ function M.edit_query(lang)
 | 
				
			|||||||
      api.nvim_buf_clear_namespace(query_buf, edit_ns, 0, -1)
 | 
					      api.nvim_buf_clear_namespace(query_buf, edit_ns, 0, -1)
 | 
				
			||||||
    end,
 | 
					    end,
 | 
				
			||||||
  })
 | 
					  })
 | 
				
			||||||
  api.nvim_create_autocmd('BufHidden', {
 | 
					  api.nvim_create_autocmd({ 'BufHidden', 'BufUnload' }, {
 | 
				
			||||||
    group = group,
 | 
					    group = group,
 | 
				
			||||||
    buffer = buf,
 | 
					    buffer = buf,
 | 
				
			||||||
    desc = 'Close the editor window when the source buffer is hidden',
 | 
					    desc = 'Close the editor window when the source buffer is hidden or unloaded',
 | 
				
			||||||
    once = true,
 | 
					    once = true,
 | 
				
			||||||
    callback = function()
 | 
					    callback = function()
 | 
				
			||||||
      close_win(query_win)
 | 
					      close_win(query_win)
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user