Skip to content

Commit 7167958

Browse files
committed
Copilot.vim 1.47.0
1 parent 8d1e0f8 commit 7167958

File tree

7 files changed

+486
-499
lines changed

7 files changed

+486
-499
lines changed

autoload/copilot.vim

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -211,9 +211,9 @@ function! s:SuggestionTextWithAdjustments() abort
211211
endif
212212
let delete = strpart(line, offset, end_offset - offset)
213213
if typed =~# '^\s*$'
214-
let leading = matchstr(choice_text, '^\s\+')
214+
let leading = strpart(matchstr(choice_text, '^\s\+'), 0, len(typed))
215215
let unindented = strpart(choice_text, len(leading))
216-
if strpart(typed, 0, len(leading)) == leading && unindented !=# delete
216+
if strpart(typed, 0, len(leading)) ==# leading && unindented !=# delete
217217
return [unindented, len(typed) - len(leading), strchars(delete), choice]
218218
endif
219219
elseif typed ==# strpart(choice_text, 0, offset)

autoload/copilot/client.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -469,7 +469,7 @@ function! s:NvimClose() dict abort
469469
return
470470
endif
471471
let self.kill = v:true
472-
return luaeval('vim.lsp.get_client_by_id(_A).stop()', self.client_id)
472+
return luaeval('vim.lsp.stop_client(_A)', self.client_id)
473473
endfunction
474474

475475
function! s:NvimNotify(method, params) dict abort

autoload/copilot/panel.vim

Lines changed: 4 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -86,9 +86,11 @@ function! copilot#panel#Accept(...) abort
8686
endif
8787
let lines = split(item.insertText, "\n", 1)
8888
let old_first = getbufline(state.bufnr, item.range.start.line + 1)[0]
89-
let lines[0] = strpart(old_first, 0, copilot#util#UTF16ToByteIdx(old_first, item.range.start.character)) . lines[0]
89+
let byte_offset_start = copilot#util#UTF16ToByteIdx(old_first, item.range.start.character)
90+
let lines[0] = strpart(old_first, 0, byte_offset_start) . lines[0]
9091
let old_last = getbufline(state.bufnr, item.range.end.line + 1)[0]
91-
let lines[-1] .= strpart(old_last, copilot#util#UTF16ToByteIdx(old_last, item.range.end.character))
92+
let byte_offset_end = copilot#util#UTF16ToByteIdx(old_last, item.range.end.character)
93+
let lines[-1] .= strpart(old_last, byte_offset_end)
9294
call deletebufline(state.bufnr, item.range.start.line + 1, item.range.end.line + 1)
9395
call appendbufline(state.bufnr, item.range.start.line, lines)
9496
call copilot#Request('workspace/executeCommand', item.command)

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.46.0'
2+
return '1.47.0'
33
endfunction

dist/main.js

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

dist/main.js.map

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

lua/_copilot.lua

Lines changed: 11 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,10 @@ copilot.lsp_start_client = function(cmd, handler_names, opts, settings)
2828
if #workspace_folders == 0 then
2929
workspace_folders = nil
3030
end
31-
id = (vim.lsp.start or vim.lsp.start_client)({
31+
-- start_client() is deprecated, but the replacement start() breaks our
32+
-- restart workflow by returning the old client that's shutting down.
33+
-- https://github.com/neovim/neovim/issues/33616
34+
id = vim.lsp.start_client({
3235
cmd = cmd,
3336
cmd_cwd = vim.call('copilot#job#Cwd'),
3437
name = 'GitHub Copilot',
@@ -60,9 +63,14 @@ copilot.lsp_request = function(client_id, method, params, bufnr)
6063
bufnr = nil
6164
end
6265
local _, id
63-
_, id = client.request(method, params, function(err, result)
66+
local handler = function(err, result)
6467
vim.call('copilot#client#LspResponse', client_id, { id = id, error = err, result = result })
65-
end, bufnr)
68+
end
69+
if vim.fn.has('nvim-0.11') == 1 then
70+
_, id = client:request(method, params, handler, bufnr)
71+
else
72+
_, id = client.request(method, params, handler, bufnr)
73+
end
6674
return id
6775
end
6876

0 commit comments

Comments
 (0)