mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 09:44:31 +00:00 
			
		
		
		
	fix(diagnostic): broken variable reference #31557
This commit is contained in:
		
				
					committed by
					
						
						GitHub
					
				
			
			
				
	
			
			
			
						parent
						
							130f4344cf
						
					
				
				
					commit
					de794f2d24
				
			@@ -854,10 +854,11 @@ local function set_list(loclist, opts)
 | 
				
			|||||||
  -- numbers beyond the end of the buffer
 | 
					  -- numbers beyond the end of the buffer
 | 
				
			||||||
  local diagnostics = get_diagnostics(bufnr, opts --[[@as vim.diagnostic.GetOpts]], false)
 | 
					  local diagnostics = get_diagnostics(bufnr, opts --[[@as vim.diagnostic.GetOpts]], false)
 | 
				
			||||||
  local items = M.toqflist(diagnostics)
 | 
					  local items = M.toqflist(diagnostics)
 | 
				
			||||||
 | 
					  local qf_id = nil
 | 
				
			||||||
  if loclist then
 | 
					  if loclist then
 | 
				
			||||||
    vim.fn.setloclist(winnr, {}, 'u', { title = title, items = items })
 | 
					    vim.fn.setloclist(winnr, {}, 'u', { title = title, items = items })
 | 
				
			||||||
  else
 | 
					  else
 | 
				
			||||||
    local qf_id = get_qf_id_for_title(title)
 | 
					    qf_id = get_qf_id_for_title(title)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
    -- If we already have a diagnostics quickfix, update it rather than creating a new one.
 | 
					    -- If we already have a diagnostics quickfix, update it rather than creating a new one.
 | 
				
			||||||
    -- This avoids polluting the finite set of quickfix lists, and preserves the currently selected
 | 
					    -- This avoids polluting the finite set of quickfix lists, and preserves the currently selected
 | 
				
			||||||
@@ -868,16 +869,17 @@ local function set_list(loclist, opts)
 | 
				
			|||||||
      id = qf_id,
 | 
					      id = qf_id,
 | 
				
			||||||
    })
 | 
					    })
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  if open then
 | 
					  if open then
 | 
				
			||||||
    if loclist then
 | 
					    if qf_id then
 | 
				
			||||||
      api.nvim_command('lwindow')
 | 
					 | 
				
			||||||
    else
 | 
					 | 
				
			||||||
      -- First navigate to the diagnostics quickfix list.
 | 
					      -- First navigate to the diagnostics quickfix list.
 | 
				
			||||||
      local nr = vim.fn.getqflist({ id = _qf_id, nr = 0 }).nr
 | 
					      local nr = vim.fn.getqflist({ id = qf_id, nr = 0 }).nr
 | 
				
			||||||
      api.nvim_command(nr .. 'chistory')
 | 
					      api.nvim_command(nr .. 'chistory')
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      -- Now open the quickfix list.
 | 
					      -- Now open the quickfix list.
 | 
				
			||||||
      api.nvim_command('botright cwindow')
 | 
					      api.nvim_command('botright cwindow')
 | 
				
			||||||
 | 
					    else
 | 
				
			||||||
 | 
					      api.nvim_command('lwindow')
 | 
				
			||||||
    end
 | 
					    end
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
end
 | 
					end
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user