mirror of
				https://github.com/neovim/neovim.git
				synced 2025-10-26 12:27:24 +00:00 
			
		
		
		
	fix(diagnostic): accept multiple namespace in open_float() (#34073)
				
					
				
			This commit is contained in:
		 Maria José Solano
					Maria José Solano
				
			
				
					committed by
					
						 GitHub
						GitHub
					
				
			
			
				
	
			
			
			 GitHub
						GitHub
					
				
			
						parent
						
							19efabafc5
						
					
				
				
					commit
					2e0158650a
				
			| @@ -546,7 +546,8 @@ Lua module: vim.diagnostic                                    *diagnostic-api* | |||||||
|     Fields: ~ |     Fields: ~ | ||||||
|       • {bufnr}?          (`integer`, default: current buffer) Buffer number |       • {bufnr}?          (`integer`, default: current buffer) Buffer number | ||||||
|                           to show diagnostics from. |                           to show diagnostics from. | ||||||
|       • {namespace}?      (`integer`) Limit diagnostics to the given namespace |       • {namespace}?      (`integer|integer[]`) Limit diagnostics to the given | ||||||
|  |                           namespace(s). | ||||||
|       • {scope}?          (`'line'|'buffer'|'cursor'|'c'|'l'|'b'`, default: |       • {scope}?          (`'line'|'buffer'|'cursor'|'c'|'l'|'b'`, default: | ||||||
|                           `line`) Show diagnostics from the whole buffer |                           `line`) Show diagnostics from the whole buffer | ||||||
|                           (`buffer"`, the current cursor line (`line`), or the |                           (`buffer"`, the current cursor line (`line`), or the | ||||||
|   | |||||||
| @@ -115,8 +115,8 @@ end | |||||||
| --- (default: current buffer) | --- (default: current buffer) | ||||||
| --- @field bufnr? integer | --- @field bufnr? integer | ||||||
| --- | --- | ||||||
| --- Limit diagnostics to the given namespace | --- Limit diagnostics to the given namespace(s). | ||||||
| --- @field namespace? integer | --- @field namespace? integer|integer[] | ||||||
| --- | --- | ||||||
| --- Show diagnostics from the whole buffer (`buffer"`, the current cursor line | --- Show diagnostics from the whole buffer (`buffer"`, the current cursor line | ||||||
| --- (`line`), or the current cursor position (`cursor`). Shorthand versions | --- (`line`), or the current cursor position (`cursor`). Shorthand versions | ||||||
|   | |||||||
| @@ -2997,7 +2997,7 @@ describe('vim.diagnostic', function() | |||||||
|  |  | ||||||
|     it('allows filtering by namespace', function() |     it('allows filtering by namespace', function() | ||||||
|       eq( |       eq( | ||||||
|         2, |         { 'Diagnostics:', '1. Syntax error' }, | ||||||
|         exec_lua(function() |         exec_lua(function() | ||||||
|           local ns_1_diagnostics = { |           local ns_1_diagnostics = { | ||||||
|             _G.make_error('Syntax error', 0, 1, 0, 3), |             _G.make_error('Syntax error', 0, 1, 0, 3), | ||||||
| @@ -3012,7 +3012,31 @@ describe('vim.diagnostic', function() | |||||||
|             vim.diagnostic.open_float(_G.diagnostic_bufnr, { namespace = _G.diagnostic_ns }) |             vim.diagnostic.open_float(_G.diagnostic_bufnr, { namespace = _G.diagnostic_ns }) | ||||||
|           local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false) |           local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false) | ||||||
|           vim.api.nvim_win_close(winnr, true) |           vim.api.nvim_win_close(winnr, true) | ||||||
|           return #lines |           return lines | ||||||
|  |         end) | ||||||
|  |       ) | ||||||
|  |     end) | ||||||
|  |  | ||||||
|  |     it('allows filtering by multiple namespaces', function() | ||||||
|  |       eq( | ||||||
|  |         { 'Diagnostics:', '1. Syntax error', '2. Some warning' }, | ||||||
|  |         exec_lua(function() | ||||||
|  |           local ns_1_diagnostics = { | ||||||
|  |             _G.make_error('Syntax error', 0, 1, 0, 3), | ||||||
|  |           } | ||||||
|  |           local ns_2_diagnostics = { | ||||||
|  |             _G.make_warning('Some warning', 0, 1, 0, 3), | ||||||
|  |           } | ||||||
|  |           vim.api.nvim_win_set_buf(0, _G.diagnostic_bufnr) | ||||||
|  |           vim.diagnostic.set(_G.diagnostic_ns, _G.diagnostic_bufnr, ns_1_diagnostics) | ||||||
|  |           vim.diagnostic.set(_G.other_ns, _G.diagnostic_bufnr, ns_2_diagnostics) | ||||||
|  |           local float_bufnr, winnr = vim.diagnostic.open_float( | ||||||
|  |             _G.diagnostic_bufnr, | ||||||
|  |             { namespace = { _G.diagnostic_ns, _G.other_ns } } | ||||||
|  |           ) | ||||||
|  |           local lines = vim.api.nvim_buf_get_lines(float_bufnr, 0, -1, false) | ||||||
|  |           vim.api.nvim_win_close(winnr, true) | ||||||
|  |           return lines | ||||||
|         end) |         end) | ||||||
|       ) |       ) | ||||||
|     end) |     end) | ||||||
|   | |||||||
		Reference in New Issue
	
	Block a user