trouble.nvim icon indicating copy to clipboard operation
trouble.nvim copied to clipboard

fix: ensure that the diagnostic parameters are complete

Open 0x7a7a opened this issue 3 years ago • 1 comments

fix #156

debug

  1. The range.start.character field may not exist
  2. The range.end field may not exist

log

{                                                                                                                                                                                                                                               
  bufnr = 6,                                                                                                                                                                                                                                    
  col = 12,                                                                                                                                                                                                                                     
  end_col = 27,                                                                                                                                                                                                                                 
  end_lnum = 74,                                                                                                                                                                                                                                
  lnum = 74,                                                                                                                                                                                                                                    
  message = "could use strings.ReplaceAll instead",                                                                                                                                                                                             
  namespace = 25,                                                                                                                                                                                                                               
  range = {                                                                                                                                                                                                                                     
    start = {                                                                                                                                                                                                                                   
      line = 74                                                                                                                                                                                                                                 
    }                                                                                                                                                                                                                                           
  },                                                                                                                                                                                                                                            
  severity = 4,                                                                                                                                                                                                                                 
  source = "QF1004",                                                                                                                                                                                                                            
  user_data = {                                                                                                                                                                                                                                 
    lsp = {}                                                                                                                                                                                                                                    
  }                                                                                                                                                                                                                                             
} 

0x7a7a avatar Apr 28 '22 09:04 0x7a7a

@folke Can we just change it to:

local start = {
  line = item.col,
  character = item.lnum,
}
local finish = {
  line = item.end_col,
  character = item.end_lnum,
}

Looks the same as the value in range

0x7a7a avatar Apr 28 '22 09:04 0x7a7a

This is what I was going to fix. The range field seems to be not defined in Neovim docs and some LSP, e.g. lua-ls, emit diagnostic items with range field but without end field in it.

ryo33 avatar Feb 19 '23 09:02 ryo33

Sorry for the late reply. Thanks!

folke avatar Feb 19 '23 09:02 folke