@@ -726,6 +726,12 @@ T['Manual completion']['works with two-step completion'] = function()
726
726
eq (get_completion (), { ' Jackpot' })
727
727
end
728
728
729
+ T [' Manual completion' ][' handles request errors' ] = function ()
730
+ child .lua (' _G.mock_completion_error = "Error"' )
731
+ type_keys (' i' , ' J' , ' <C-Space>' )
732
+ eq (get_completion (), { ' Jackpot' })
733
+ end
734
+
729
735
T [' Manual completion' ][' uses `vim.lsp.protocol.CompletionItemKind` in LSP step' ] = function ()
730
736
child .set_size (17 , 30 )
731
737
child .lua ([[ vim.lsp.protocol.CompletionItemKind = {
@@ -1016,6 +1022,14 @@ T['Information window']['works'] = function()
1016
1022
child .expect_screenshot ()
1017
1023
end
1018
1024
1025
+ T [' Information window' ][' handles request errors' ] = function ()
1026
+ child .lua (' _G.mock_resolve_error = "Error"' )
1027
+ type_keys (' i' , ' J' , ' <C-Space>' )
1028
+ type_keys (' <C-n>' )
1029
+ sleep (default_info_delay + small_time )
1030
+ eq (get_floating_windows (), {})
1031
+ end
1032
+
1019
1033
T [' Information window' ][' respects `config.delay.info`' ] = function ()
1020
1034
child .lua (' MiniCompletion.config.delay.info = ' .. (2 * default_info_delay ))
1021
1035
validate_info_win (2 * default_info_delay )
@@ -1252,6 +1266,13 @@ T['Signature help']['works'] = function()
1252
1266
child .expect_screenshot ()
1253
1267
end
1254
1268
1269
+ T [' Signature help' ][' handles request errors' ] = function ()
1270
+ child .lua (' _G.mock_signature_error = "Error"' )
1271
+ type_keys (' i' , ' abc(' )
1272
+ sleep (default_signature_delay + small_time )
1273
+ eq (get_floating_windows (), {})
1274
+ end
1275
+
1255
1276
T [' Signature help' ][' respects `config.delay.signature`' ] = function ()
1256
1277
child .lua (' MiniCompletion.config.delay.signature = ' .. (2 * default_signature_delay ))
1257
1278
validate_signature_win (2 * default_signature_delay )
@@ -1888,20 +1909,33 @@ T['Snippets']['prefer snippet from resolved item'] = function()
1888
1909
-- or `textEdti` in 'completionItem/resolve', this still can probably happen.
1889
1910
1890
1911
child .lua ([[
1912
+ local error_field = vim.fn.has('nvim-0.11') == 1 and 'err' or 'error'
1891
1913
local buf_request_all_orig = vim.lsp.buf_request_all
1892
1914
vim.lsp.buf_request_all = function(bufnr, method, params, callback)
1893
1915
if method ~= 'completionItem/resolve' then return buf_request_all_orig(bufnr, method, params, callback) end
1894
1916
params.textEdit = { newText = 'Snippet $1 from resolve' }
1895
- callback({ { result = params } })
1917
+ callback({ { [error_field] = _G.resolve_error, result = _G.resolve_error == nil and params or nil } })
1896
1918
end
1897
1919
]] )
1898
1920
1921
+ local validate = function (ref_lines )
1922
+ type_keys (' i' , ' <C-Space>' , ' <C-n>' )
1923
+ -- - Wait for 'completionItem/resolve' request to be sent
1924
+ sleep (default_info_delay + small_time )
1925
+ type_keys (' <C-y>' )
1926
+ eq (get_lines (), ref_lines )
1927
+
1928
+ type_keys (' <C-c>' )
1929
+ set_lines ({})
1930
+ child .ensure_normal_mode ()
1931
+ end
1932
+
1899
1933
mock_lsp_snippets ({ ' Snippet $1 original' })
1900
- type_keys ( ' i ' , ' <C-Space> ' , ' <C-n> ' )
1901
- -- - Wait for 'completionItem/resolve' request to be sent
1902
- sleep ( default_info_delay + small_time )
1903
- type_keys ( ' <C-y> ' )
1904
- eq ( get_lines (), { ' Snippet from resolve ' })
1934
+ validate ({ ' Snippet from resolve ' } )
1935
+
1936
+ -- Should handle error in 'completionItem/resolve' response
1937
+ child . lua ( ' _G.resolve_error = "Error" ' )
1938
+ validate ( { ' Snippet original ' })
1905
1939
end
1906
1940
1907
1941
T [' Snippets' ][' can be inserted together with additional text edits' ] = function ()
0 commit comments