@@ -471,15 +471,41 @@ end
471
471
T [' Manual completion' ][' prefers completion range from LSP response' ] = function ()
472
472
set_lines ({})
473
473
type_keys (' i' , ' months.' )
474
- child .lua (' _G.mock_textEdit_pos = vim.api.nvim_win_get_cursor(0)' )
474
+ -- Mock `textEdit` as in `tsserver` when called after `.`
475
+ child .lua ([[ _G.mock_textEdit = {
476
+ pos = vim.api.nvim_win_get_cursor(0),
477
+ new_text = function(name) return '.' .. name end,
478
+ } ]] )
475
479
type_keys (' <C-space>' )
476
480
477
- eq (get_completion (), { ' .April' , ' .August' })
481
+ eq (get_completion (' abbr' ), { ' April' , ' August' })
482
+ eq (get_completion (' word' ), { ' .April' , ' .August' })
478
483
type_keys (' <C-n>' , ' <C-y>' )
479
484
eq (get_lines (), { ' months.April' })
480
485
eq (get_cursor (), { 1 , 12 })
481
486
end
482
487
488
+ T [' Manual completion' ][' respects `filterText` from LSP response' ] = function ()
489
+ set_lines ({})
490
+ type_keys (' i' , ' months.' )
491
+ -- Mock `textEdit` and `filterText` as in `tsserver` when called after `.`
492
+ -- (see https://github.com/echasnovski/mini.nvim/issues/306#issuecomment-1602245446)
493
+ child .lua ([[
494
+ _G.mock_textEdit = {
495
+ pos = vim.api.nvim_win_get_cursor(0),
496
+ new_text = function(name) return '[' .. name .. ']' end,
497
+ }
498
+ _G.mock_filterText = function(name) return '.' .. name end
499
+ ]] )
500
+ type_keys (' <C-space>' )
501
+
502
+ eq (get_completion (' abbr' ), { ' April' , ' August' })
503
+ eq (get_completion (' word' ), { ' [April]' , ' [August]' })
504
+ type_keys (' <C-n>' , ' <C-y>' )
505
+ eq (get_lines (), { ' months[April]' })
506
+ eq (get_cursor (), { 1 , 13 })
507
+ end
508
+
483
509
T [' Manual completion' ][' respects `vim.{g,b}.minicompletion_disable`' ] = new_set ({
484
510
parametrize = { { ' g' }, { ' b' } },
485
511
}, {
0 commit comments