@@ -384,16 +384,16 @@ function M:_setup_input_events(container)
384384 vim .api .nvim_create_autocmd (" User" , {
385385 pattern = { " CompletionItemSelected" },
386386 callback = function (event )
387- if not event .data or not event .data .path or not event .data .type then
387+ if not event .data or not event .data .context_item or not event .data .label then
388388 return
389389 end
390390
391391 if self ._contexts then
392392 self ._contexts .to_add = {
393- name = vim . fn . fnamemodify ( event .data .path , " :. " ) ,
394- type = event .data .type ,
393+ name = event .data .label ,
394+ type = event .data .context_item . type ,
395395 data = {
396- path = event .data .path
396+ path = event .data .context_item . path
397397 }
398398 }
399399 end
@@ -404,10 +404,6 @@ function M:_setup_input_events(container)
404404 vim .api .nvim_buf_attach (container .bufnr , false , {
405405 on_lines = function (_ , buf , _changedtick , first , _last , _new_last , _bytecount )
406406 vim .schedule (function ()
407- if first ~= 0 and first ~= 1 then
408- return
409- end
410-
411407 local lines = vim .api .nvim_buf_get_lines (buf , 0 , - 1 , false )
412408
413409 -- handle empty buffer
@@ -431,7 +427,10 @@ function M:_setup_input_events(container)
431427 end
432428
433429 local prefix_mark = vim .api .nvim_buf_get_extmark_by_id (buf , prefix_ns , prefix_id , {})
434- local prefix_row = unpack (prefix_mark )
430+ local prefix_row = 1
431+ if prefix_mark and type (prefix_mark ) == " table" and prefix_mark [1 ] ~= nil then
432+ prefix_row = tonumber (prefix_mark [1 ]) or 1
433+ end
435434 local contexts_row = 0
436435
437436 local prefix_line = lines [prefix_row + 1 ] or nil
@@ -485,6 +484,7 @@ function M:_setup_input_events(container)
485484 for i = 1 , # placeholders do
486485 if context_to_add .name and context_to_add .name == placeholders [i ] then
487486 self .mediator :add_context (context_to_add )
487+ self ._contexts .to_add = {}
488488 end
489489 end
490490
@@ -494,6 +494,7 @@ function M:_setup_input_events(container)
494494 self :_update_input_display ()
495495 return
496496 end
497+
497498 end )
498499 end
499500 })
@@ -750,7 +751,7 @@ function M:_update_input_display(opts)
750751
751752 for i , context_name in ipairs (contexts_name ) do
752753 self .extmarks .contexts ._id [i ] = vim .api .nvim_buf_set_extmark (
753- input .bufnr ,
754+ input .bufnr ,
754755 self .extmarks .contexts ._ns ,
755756 0 ,
756757 i ,
0 commit comments