mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	fix(lsp): properly handle nil lines when trimming empty lines (#15325)
				
					
				
			This commit is contained in:
		| @@ -1719,14 +1719,14 @@ end | |||||||
| function M.trim_empty_lines(lines) | function M.trim_empty_lines(lines) | ||||||
|   local start = 1 |   local start = 1 | ||||||
|   for i = 1, #lines do |   for i = 1, #lines do | ||||||
|     if #lines[i] > 0 then |     if lines[i] ~= nil and #lines[i] > 0 then | ||||||
|       start = i |       start = i | ||||||
|       break |       break | ||||||
|     end |     end | ||||||
|   end |   end | ||||||
|   local finish = 1 |   local finish = 1 | ||||||
|   for i = #lines, 1, -1 do |   for i = #lines, 1, -1 do | ||||||
|     if #lines[i] > 0 then |     if lines[i] ~= nil and #lines[i] > 0 then | ||||||
|       finish = i |       finish = i | ||||||
|       break |       break | ||||||
|     end |     end | ||||||
|   | |||||||
| @@ -1954,6 +1954,12 @@ describe('LSP', function() | |||||||
|     end) |     end) | ||||||
|   end) |   end) | ||||||
|  |  | ||||||
|  |   describe('lsp.util.trim.trim_empty_lines', function() | ||||||
|  |     it('properly trims empty lines', function() | ||||||
|  |       eq({{"foo", "bar"}}, exec_lua[[ return vim.lsp.util.trim_empty_lines({{ "foo", "bar" },  nil}) ]]) | ||||||
|  |     end) | ||||||
|  |   end) | ||||||
|  |  | ||||||
|   describe('lsp.util.get_effective_tabstop', function() |   describe('lsp.util.get_effective_tabstop', function() | ||||||
|     local function test_tabstop(tabsize, softtabstop) |     local function test_tabstop(tabsize, softtabstop) | ||||||
|       exec_lua(string.format([[ |       exec_lua(string.format([[ | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user
	 Andrea Cappuccio
					Andrea Cappuccio