Skip to content

Commit d1e8429

Browse files
committed
Copilot.vim 1.49.0
1 parent 18f485d commit d1e8429

34 files changed

+1709
-1519
lines changed

.gitattributes

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,2 +1,2 @@
11
*.vim eol=lf
2-
/dist/** -whitespace -diff
2+
/copilot-language-server/** -whitespace -diff

autoload/copilot.vim

Lines changed: 15 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -191,7 +191,7 @@ function! s:HideDuringCompletion() abort
191191
endfunction
192192

193193
function! s:SuggestionTextWithAdjustments() abort
194-
let empty = ['', 0, 0, {}]
194+
let empty = ['', 0, '', {}]
195195
try
196196
if mode() !~# '^[iR]' || (s:HideDuringCompletion() && pumvisible()) || !exists('b:_copilot.suggestions')
197197
return empty
@@ -215,10 +215,10 @@ function! s:SuggestionTextWithAdjustments() abort
215215
let leading = strpart(matchstr(choice_text, '^\s\+'), 0, len(typed))
216216
let unindented = strpart(choice_text, len(leading))
217217
if strpart(typed, 0, len(leading)) ==# leading && unindented !=# delete
218-
return [unindented, len(typed) - len(leading), strchars(delete), choice]
218+
return [unindented, len(typed) - len(leading), delete, choice]
219219
endif
220220
elseif typed ==# strpart(choice_text, 0, offset)
221-
return [strpart(choice_text, offset), 0, strchars(delete), choice]
221+
return [strpart(choice_text, offset), 0, delete, choice]
222222
endif
223223
catch
224224
call copilot#logger#Exception()
@@ -290,7 +290,8 @@ function! copilot#GetDisplayedSuggestion() abort
290290
\ 'item': item,
291291
\ 'text': text,
292292
\ 'outdentSize': outdent,
293-
\ 'deleteSize': delete}
293+
\ 'deleteSize': strchars(delete),
294+
\ 'deleteChars': delete}
294295
endfunction
295296

296297
function! s:ClearPreview() abort
@@ -304,7 +305,8 @@ endfunction
304305

305306
function! s:UpdatePreview() abort
306307
try
307-
let [text, outdent, delete, item] = s:SuggestionTextWithAdjustments()
308+
let [text, outdent, delete_chars, item] = s:SuggestionTextWithAdjustments()
309+
let delete = strchars(delete_chars)
308310
let text = split(text, "\r\n\\=\\|\n", 1)
309311
if empty(text[-1])
310312
call remove(text, -1)
@@ -489,6 +491,13 @@ function! copilot#Accept(...) abort
489491
if empty(text)
490492
let text = s.text
491493
endif
494+
let delete_chars = s.deleteChars
495+
let leftover = strpart(s.text, strlen(text))
496+
let idx = strridx(leftover, matchstr(delete_chars, '.$'))
497+
while !empty(delete_chars) && idx != -1
498+
let delete_chars = substitute(delete_chars, '.$', '', '')
499+
let idx = strridx(leftover, matchstr(delete_chars, '.$'), idx - 1)
500+
endwhile
492501
if text ==# s.text && has_key(s.item, 'command')
493502
call copilot#Request('workspace/executeCommand', s.item.command)
494503
else
@@ -500,7 +509,7 @@ function! copilot#Accept(...) abort
500509
call s:ClearPreview()
501510
let s:suggestion_text = text
502511
let recall = text =~# "\n" ? "\<C-R>\<C-O>=" : "\<C-R>\<C-R>="
503-
return repeat("\<Left>\<Del>", s.outdentSize) . repeat("\<Del>", s.deleteSize) .
512+
return repeat("\<Left>\<Del>", s.outdentSize) . repeat("\<Del>", strchars(delete_chars)) .
504513
\ recall . "copilot#TextQueuedForInsertion()\<CR>" . (a:0 > 1 ? '' : "\<End>")
505514
endif
506515
let default = get(g:, 'copilot_tab_fallback', pumvisible() ? "\<C-N>" : "\t")

autoload/copilot/client.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -487,7 +487,7 @@ function! copilot#client#LspHandle(id, request) abort
487487
return s:OnMessage(s:instances[a:id], a:request)
488488
endfunction
489489

490-
let s:script_name = 'dist/language-server.js'
490+
let s:script_name = 'copilot-language-server/dist/language-server.js'
491491
function! s:Command() abort
492492
if !has('nvim-0.7') && v:version < 900
493493
return [[], [], 'Vim version too old']
@@ -544,7 +544,7 @@ function! copilot#client#Settings() abort
544544
\ 'http': {
545545
\ 'proxy': get(g:, 'copilot_proxy', v:null),
546546
\ 'proxyStrictSSL': get(g:, 'copilot_proxy_strict_ssl', v:null)},
547-
\ 'github-enterprise': {'uri': get(g:, 'copilot_auth_provider_url', v:null)},
547+
\ 'github-enterprise': {'uri': get(g:, 'copilot_enterprise_uri', get(g:, 'copilot_auth_provider_url', v:null))},
548548
\ }
549549
if type(settings.http.proxy) ==# v:t_string && settings.http.proxy =~# '^[^/]\+$'
550550
let settings.http.proxy = 'http://' . settings.http.proxy

autoload/copilot/version.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,3 @@
11
function! copilot#version#String() abort
2-
return '1.48.0'
2+
return '1.49.0'
33
endfunction

0 commit comments

Comments
 (0)