mirror of
				https://github.com/neovim/neovim.git
				synced 2025-11-04 01:34:25 +00:00 
			
		
		
		
	feat(lsp.util): minor codestyle
This commit is contained in:
		@@ -1700,10 +1700,10 @@ do --[[ References ]]
 | 
				
			|||||||
    validate('bufnr', bufnr, 'number', true)
 | 
					    validate('bufnr', bufnr, 'number', true)
 | 
				
			||||||
    validate('offset_encoding', offset_encoding, 'string', false)
 | 
					    validate('offset_encoding', offset_encoding, 'string', false)
 | 
				
			||||||
    for _, reference in ipairs(references) do
 | 
					    for _, reference in ipairs(references) do
 | 
				
			||||||
      local start_line, start_char =
 | 
					      local start_line = reference.range.start.line
 | 
				
			||||||
        reference['range']['start']['line'], reference['range']['start']['character']
 | 
					      local start_char = reference.range.start.character
 | 
				
			||||||
      local end_line, end_char =
 | 
					      local end_line = reference.range['end'].line
 | 
				
			||||||
        reference['range']['end']['line'], reference['range']['end']['character']
 | 
					      local end_char = reference.range['end'].character
 | 
				
			||||||
 | 
					
 | 
				
			||||||
      local start_idx = get_line_byte_from_position(
 | 
					      local start_idx = get_line_byte_from_position(
 | 
				
			||||||
        bufnr,
 | 
					        bufnr,
 | 
				
			||||||
@@ -1772,8 +1772,7 @@ function M.locations_to_items(locations, offset_encoding)
 | 
				
			|||||||
    table.insert(grouped[uri], { start = range.start, ['end'] = range['end'], location = d })
 | 
					    table.insert(grouped[uri], { start = range.start, ['end'] = range['end'], location = d })
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
 | 
					
 | 
				
			||||||
  for uri in vim.spairs(grouped) do
 | 
					  for uri, rows in vim.spairs(grouped) do
 | 
				
			||||||
    local rows = grouped[uri]
 | 
					 | 
				
			||||||
    table.sort(rows, position_sort)
 | 
					    table.sort(rows, position_sort)
 | 
				
			||||||
    local filename = vim.uri_to_fname(uri)
 | 
					    local filename = vim.uri_to_fname(uri)
 | 
				
			||||||
 | 
					
 | 
				
			||||||
@@ -2008,19 +2007,19 @@ function M.make_given_range_params(start_pos, end_pos, bufnr, offset_encoding)
 | 
				
			|||||||
  validate('offset_encoding', offset_encoding, 'string', true)
 | 
					  validate('offset_encoding', offset_encoding, 'string', true)
 | 
				
			||||||
  bufnr = bufnr or api.nvim_get_current_buf()
 | 
					  bufnr = bufnr or api.nvim_get_current_buf()
 | 
				
			||||||
  offset_encoding = offset_encoding or M._get_offset_encoding(bufnr)
 | 
					  offset_encoding = offset_encoding or M._get_offset_encoding(bufnr)
 | 
				
			||||||
  --- @type integer[]
 | 
					  --- @type [integer, integer]
 | 
				
			||||||
  local A = list_extend({}, start_pos or api.nvim_buf_get_mark(bufnr, '<'))
 | 
					  local A = { unpack(start_pos or api.nvim_buf_get_mark(bufnr, '<')) }
 | 
				
			||||||
  --- @type integer[]
 | 
					  --- @type [integer, integer]
 | 
				
			||||||
  local B = list_extend({}, end_pos or api.nvim_buf_get_mark(bufnr, '>'))
 | 
					  local B = { unpack(end_pos or api.nvim_buf_get_mark(bufnr, '>')) }
 | 
				
			||||||
  -- convert to 0-index
 | 
					  -- convert to 0-index
 | 
				
			||||||
  A[1] = A[1] - 1
 | 
					  A[1] = A[1] - 1
 | 
				
			||||||
  B[1] = B[1] - 1
 | 
					  B[1] = B[1] - 1
 | 
				
			||||||
  -- account for offset_encoding.
 | 
					  -- account for offset_encoding.
 | 
				
			||||||
  if A[2] > 0 then
 | 
					  if A[2] > 0 then
 | 
				
			||||||
    A = { A[1], M.character_offset(bufnr, A[1], A[2], offset_encoding) }
 | 
					    A[2] = M.character_offset(bufnr, A[1], A[2], offset_encoding)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  if B[2] > 0 then
 | 
					  if B[2] > 0 then
 | 
				
			||||||
    B = { B[1], M.character_offset(bufnr, B[1], B[2], offset_encoding) }
 | 
					    B[2] = M.character_offset(bufnr, B[1], B[2], offset_encoding)
 | 
				
			||||||
  end
 | 
					  end
 | 
				
			||||||
  -- we need to offset the end character position otherwise we loose the last
 | 
					  -- we need to offset the end character position otherwise we loose the last
 | 
				
			||||||
  -- character of the selection, as LSP end position is exclusive
 | 
					  -- character of the selection, as LSP end position is exclusive
 | 
				
			||||||
 
 | 
				
			|||||||
		Reference in New Issue
	
	Block a user