Skip to content

Commit 1358e8e

Browse files
committed
Copilot.vim 1.8.4
1 parent b6e5624 commit 1358e8e

File tree

8 files changed

+150604
-33
lines changed

8 files changed

+150604
-33
lines changed

LICENSE.md

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
11
GitHub Copilot is offered under the [GitHub Terms of
2-
Service](hhttps://docs.github.com/en/site-policy/github-terms/github-terms-for-additional-products-and-features#github-copilot).
2+
Service](https://docs.github.com/en/site-policy/github-terms/github-terms-for-additional-products-and-features#github-copilot).
33

44
Copyright (C) 2023 GitHub, Inc. - All Rights Reserved.

autoload/copilot.vim

Lines changed: 13 additions & 12 deletions
Original file line numberDiff line numberDiff line change
@@ -206,12 +206,17 @@ function! s:SuggestionTextWithAdjustments() abort
206206
return ['', 0, 0, '']
207207
endif
208208
let typed = strpart(line, 0, offset)
209-
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
209+
if exists('*utf16idx')
210+
let end_offset = byteidx(line, choice.range.end.character, 1)
211+
elseif has('nvim')
212+
let end_offset = v:lua.vim.str_byteindex(line, choice.range.end.character, 1)
212213
else
213-
let append = ''
214+
let end_offset = len(line)
215+
while copilot#doc#UTF16Width(strpart(line, 0, end_offset)) > choice.range.end.character && end_offset > 0
216+
let end_offset -= 1
217+
endwhile
214218
endif
219+
let delete = strpart(line, offset, end_offset - offset)
215220
let uuid = get(choice, 'uuid', '')
216221
if typed =~# '^\s*$'
217222
let leading = matchstr(choice.text, '^\s\+')
@@ -220,7 +225,7 @@ function! s:SuggestionTextWithAdjustments() abort
220225
return [unindented, len(typed) - len(leading), strchars(delete), uuid]
221226
endif
222227
elseif typed ==# strpart(choice.text, 0, offset)
223-
return [strpart(choice.text . append, offset), 0, strchars(delete), uuid]
228+
return [strpart(choice.text, offset), 0, strchars(delete), uuid]
224229
endif
225230
catch
226231
call copilot#logger#Exception()
@@ -369,7 +374,8 @@ function! s:UpdatePreview() abort
369374
if s:has_nvim_ghost_text
370375
let data = {'id': 1}
371376
let data.virt_text_win_col = virtcol('.') - 1
372-
let data.virt_text = [[text[0] . repeat(' ', delete - len(text[0])), s:hlgroup]]
377+
let append = strpart(getline('.'), col('.') - 1 + delete)
378+
let data.virt_text = [[text[0] . append . repeat(' ', delete - len(text[0])), s:hlgroup]]
373379
if len(text) > 1
374380
let data.virt_lines = map(text[1:-1], { _, l -> [[l, s:hlgroup]] })
375381
if !empty(annot)
@@ -381,11 +387,6 @@ function! s:UpdatePreview() abort
381387
let data.hl_mode = 'combine'
382388
call nvim_buf_set_extmark(0, copilot#NvimNs(), line('.')-1, col('.')-1, data)
383389
else
384-
let trail = strpart(getline('.'), col('.') - 1)
385-
while !empty(trail) && trail[-1] ==# text[0][-1]
386-
let trail = trail[:-2]
387-
let text[0] = text[0][:-2]
388-
endwhile
389390
call prop_add(line('.'), col('.'), {'type': s:hlgroup, 'text': text[0]})
390391
for line in text[1:]
391392
call prop_add(line('.'), 0, {'type': s:hlgroup, 'text_align': 'below', 'text': line})
@@ -490,7 +491,7 @@ function! copilot#Accept(...) abort
490491
call s:ClearPreview()
491492
let s:suggestion_text = s.text
492493
return repeat("\<Left>\<Del>", s.outdentSize) . repeat("\<Del>", s.deleteSize) .
493-
\ "\<C-R>\<C-O>=copilot#TextQueuedForInsertion()\<CR>"
494+
\ "\<C-R>\<C-O>=copilot#TextQueuedForInsertion()\<CR>\<End>"
494495
endif
495496
let default = get(g:, 'copilot_tab_fallback', pumvisible() ? "\<C-N>" : "\t")
496497
if !a:0

autoload/copilot/agent.vim

Lines changed: 4 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -5,7 +5,7 @@ let g:autoloaded_copilot_agent = 1
55

66
scriptencoding utf-8
77

8-
let s:plugin_version = '1.8.3'
8+
let s:plugin_version = '1.8.4'
99

1010
let s:error_exit = -1
1111

@@ -453,7 +453,7 @@ function! copilot#agent#EditorInfo() abort
453453
else
454454
let proxy = ''
455455
endif
456-
let match = matchlist(proxy, '\c^\%([^:]\+://\)\=\%(\([^/:#]\+@\)\)\=\%(\([^/:#]\+\)\|\[\([[:xdigit:]:]\+\)\]\)\%(:\(\d\+\)\)\=\%(/\|$\|?strict_\=ssl=\(.*\)\)')
456+
let match = matchlist(proxy, '\c^\%([^:]\+://\)\=\%(\([^/#]\+@\)\)\=\%(\([^/:#]\+\)\|\[\([[:xdigit:]:]\+\)\]\)\%(:\(\d\+\)\)\=\%(/\|$\|?strict_\=ssl=\(.*\)\)')
457457
if !empty(match)
458458
let info.networkProxy = {'host': match[2] . match[3], 'port': empty(match[4]) ? 80 : +match[4]}
459459
if match[5] =~? '^[0f]'
@@ -464,8 +464,8 @@ function! copilot#agent#EditorInfo() abort
464464
let info.networkProxy.rejectUnauthorized = empty(g:copilot_proxy_strict_ssl) ? v:false : v:true
465465
endif
466466
if !empty(match[1])
467-
let info.networkProxy.username = s:UrlDecode(matchstr(match[1], '^[^:]*'))
468-
let info.networkProxy.password = s:UrlDecode(matchstr(match[1], ':\zs.*'))
467+
let info.networkProxy.username = s:UrlDecode(matchstr(match[1], '^[^:@]*'))
468+
let info.networkProxy.password = s:UrlDecode(matchstr(match[1], ':\zs[^@]*'))
469469
endif
470470
endif
471471
return info

copilot/dist/agent.js

Lines changed: 5 additions & 5 deletions
Some generated files are not rendered by default. Learn more about customizing how changed files appear on GitHub.

copilot/dist/agent.js.LICENSE.txt

Lines changed: 18 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,8 @@
1+
/*!
2+
* Application Insights JavaScript SDK - Web Snippet, 1.0.1
3+
* Copyright (c) Microsoft and contributors. All rights reserved.
4+
*/
5+
16
/*!
27
* buildToken
38
* Builds OAuth token prefix (helper function)
@@ -8,6 +13,19 @@
813
* @return {String} token prefix
914
*/
1015

16+
/*!
17+
* mime-db
18+
* Copyright(c) 2014 Jonathan Ong
19+
* MIT Licensed
20+
*/
21+
22+
/*!
23+
* mime-types
24+
* Copyright(c) 2014 Jonathan Ong
25+
* Copyright(c) 2015 Douglas Christopher Wilson
26+
* MIT Licensed
27+
*/
28+
1129
/** @license URI.js v4.4.1 (c) 2011 Gary Court. License: http://github.com/garycourt/uri-js */
1230

1331
/** @preserve

copilot/dist/tokenizer_cushman001.json

Lines changed: 50283 additions & 1 deletion
Large diffs are not rendered by default.

copilot/dist/tokenizer_cushman002.json

Lines changed: 100260 additions & 1 deletion
Large diffs are not rendered by default.

plugin/copilot.vim

Lines changed: 20 additions & 9 deletions
Original file line numberDiff line numberDiff line change
@@ -73,15 +73,26 @@ if !get(g:, 'copilot_no_maps')
7373
imap <Plug>(copilot-next) <Cmd>call copilot#Next()<CR>
7474
imap <Plug>(copilot-previous) <Cmd>call copilot#Previous()<CR>
7575
imap <Plug>(copilot-suggest) <Cmd>call copilot#Suggest()<CR>
76-
if empty(mapcheck('<M-]>', 'i'))
77-
imap <M-]> <Plug>(copilot-next)
78-
endif
79-
if empty(mapcheck('<M-[>', 'i'))
80-
imap <M-[> <Plug>(copilot-previous)
81-
endif
82-
if empty(mapcheck('<M-Bslash>', 'i'))
83-
imap <M-Bslash> <Plug>(copilot-suggest)
84-
endif
76+
try
77+
if !has('nvim') && &encoding ==# 'utf-8'
78+
" avoid 8-bit meta collision with UTF-8 characters
79+
let s:restore_encoding = 1
80+
set encoding=cp949
81+
endif
82+
if empty(mapcheck('<M-]>', 'i'))
83+
imap <M-]> <Plug>(copilot-next)
84+
endif
85+
if empty(mapcheck('<M-[>', 'i'))
86+
imap <M-[> <Plug>(copilot-previous)
87+
endif
88+
if empty(mapcheck('<M-Bslash>', 'i'))
89+
imap <M-Bslash> <Plug>(copilot-suggest)
90+
endif
91+
finally
92+
if exists('s:restore_encoding')
93+
set encoding=utf-8
94+
endif
95+
endtry
8596
endif
8697

8798
call copilot#Init()

0 commit comments

Comments
 (0)