@@ -19,14 +19,22 @@ if s:has_vim_ghost_text && empty(prop_type_get(s:annot_hlgroup))
1919 call prop_type_add (s: annot_hlgroup , {' highlight' : s: annot_hlgroup })
2020endif
2121
22+ function ! s: Echo (msg) abort
23+ if has (' nvim' ) && &cmdheight == 0
24+ call v: lua .vim .notify (a: msg , v: null , {' title' : ' GitHub Copilot' })
25+ else
26+ echo a: msg
27+ endif
28+ endfunction
29+
2230function ! s: EditorConfiguration () abort
2331 let filetypes = copy (s: filetype_defaults )
2432 if type (get (g: , ' copilot_filetypes' )) == v: t_dict
2533 call extend (filetypes, g: copilot_filetypes )
2634 endif
2735 return {
2836 \ ' enableAutoCompletions' : empty (get (g: , ' copilot_enabled' , 1 )) ? v: false : v: true ,
29- \ ' disabledLanguages' : map (sort (keys (filter (filetypes, { k , v - > empty (v ) ? v: true : v: false }))), { _, v - > {' languageId' : v }}),
37+ \ ' disabledLanguages' : map (sort (keys (filter (filetypes, { k , v - > empty (v ) }))), { _, v - > {' languageId' : v }}),
3038 \ }
3139endfunction
3240
@@ -199,6 +207,11 @@ function! s:SuggestionTextWithAdjustments() abort
199207 endif
200208 let typed = strpart (line , 0 , offset)
201209 let delete = strpart (line , offset)
210+ if choice.range .end .line == line (' .' ) - 1 && choice.range .end .character < copilot#doc#UTF16Width (line )
211+ let append = delete
212+ else
213+ let append = ' '
214+ endif
202215 let uuid = get (choice, ' uuid' , ' ' )
203216 if typed = ~# ' ^\s*$'
204217 let leading = matchstr (choice.text, ' ^\s\+' )
@@ -207,7 +220,7 @@ function! s:SuggestionTextWithAdjustments() abort
207220 return [unindented, len (typed) - len (leading), strchars (delete ), uuid]
208221 endif
209222 elseif typed == # strpart (choice.text, 0 , offset)
210- return [strpart (choice.text . delete , offset), 0 , strchars (delete ), uuid]
223+ return [strpart (choice.text . append , offset), 0 , strchars (delete ), uuid]
211224 endif
212225 catch
213226 call copilot#logger#Exception ()
@@ -439,6 +452,9 @@ endfunction
439452function ! copilot#OnInsertEnter () abort
440453 let s: is_mapped = copilot#IsMapped ()
441454 let s: dest = bufnr (' ^copilot://$' )
455+ if s: dest > 0 && bufwinnr (s: dest ) < 0
456+ let s: dest = -1
457+ endif
442458 if s: dest < 0 && ! s: has_ghost_text
443459 let s: dest = 0
444460 endif
@@ -622,16 +638,16 @@ function! s:commands.setup(opts) abort
622638 let @+ = data.userCode
623639 let @* = data.userCode
624640 endif
625- echo " First copy your one-time code: " . data.userCode
641+ call s: Echo ( " First copy your one-time code: " . data.userCode)
626642 try
627643 if len (&mouse )
628644 let mouse = &mouse
629645 set mouse =
630646 endif
631647 if get (a: opts , ' bang' )
632- echo " In your browser, visit " . uri
648+ call s: Echo ( " In your browser, visit " . uri)
633649 elseif len (browser)
634- echo " Press ENTER to open GitHub in your browser"
650+ call s: Echo ( " Press ENTER to open GitHub in your browser" )
635651 let c = getchar ()
636652 while c isnot # 13 && c isnot # 10 && c isnot # 0
637653 let c = getchar ()
@@ -643,14 +659,14 @@ function! s:commands.setup(opts) abort
643659 sleep 10 m
644660 endwhile
645661 if get (status, ' code' , browser[0 ] !=# ' xdg-open' ) != 0
646- echo " Failed to open browser. Visit " . uri
662+ call s: Echo ( " Failed to open browser. Visit " . uri)
647663 else
648- echo " Opened " . uri
664+ call s: Echo ( " Opened " . uri)
649665 endif
650666 else
651- echo " Could not find browser. Visit " . uri
667+ call s: Echo ( " Could not find browser. Visit " . uri)
652668 endif
653- echo " Waiting (could take up to 5 seconds)"
669+ call s: Echo ( " Waiting (could take up to 5 seconds)" )
654670 let request = copilot#Request (' signInConfirm' , {' userCode' : data.userCode}).Wait ()
655671 finally
656672 if exists (' mouse' )
0 commit comments