Skip to content

Commit 0322dcf

Browse files
committed
Copilot.vim 1.11.2
1 parent c1d9ea4 commit 0322dcf

File tree

6 files changed

+227
-220
lines changed

6 files changed

+227
-220
lines changed

autoload/copilot.vim

Lines changed: 5 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -173,8 +173,11 @@ function! s:BufferDisabled() abort
173173
return empty(b:copilot_enabled) ? 4 : 0
174174
endif
175175
let short = empty(&l:filetype) ? '.' : split(&l:filetype, '\.', 1)[0]
176-
let config = get(g:, 'copilot_filetypes', {})
177-
if type(config) == v:t_dict && has_key(config, &l:filetype)
176+
let config = {}
177+
if type(get(g:, 'copilot_filetypes')) == v:t_dict
178+
let config = g:copilot_filetypes
179+
endif
180+
if has_key(config, &l:filetype)
178181
return empty(config[&l:filetype])
179182
elseif has_key(config, short)
180183
return empty(config[short])

autoload/copilot/agent.vim

Lines changed: 15 additions & 11 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.11.1'
8+
let s:plugin_version = '1.11.2'
99

1010
let s:error_exit = -1
1111

@@ -58,14 +58,18 @@ function! s:AgentNotify(method, params) dict abort
5858
return v:true
5959
endfunction
6060

61+
function! s:IsFinished(request) abort
62+
return a:request.status !=# 'running' && empty(get(a:request, 'waiting', {}))
63+
endfunction
64+
6165
function! s:RequestWait() dict abort
62-
while self.status ==# 'running'
63-
sleep 1m
64-
endwhile
65-
while !empty(get(self, 'waiting', {}))
66-
sleep 1m
67-
endwhile
68-
return self
66+
if exists('*wait')
67+
call wait(-1, function('s:IsFinished', [self]), 2)
68+
else
69+
while !s:IsFinished(self)
70+
sleep 2m
71+
endwhile
72+
endif
6973
endfunction
7074

7175
function! s:RequestAwait() dict abort
@@ -423,7 +427,7 @@ function! s:Command() abort
423427
endif
424428
let node_version = s:GetNodeVersion(node)
425429
let warning = ''
426-
if node_version.major < 18 && get(node, 0, '') !=# 'node' && executable('node')
430+
if !get(g:, 'copilot_ignore_node_version') && node_version.major < 18 && get(node, 0, '') !=# 'node' && executable('node')
427431
let node_version_from_path = s:GetNodeVersion(['node'])
428432
if node_version_from_path.major >= 18
429433
let warning = 'Ignoring g:copilot_node_command: Node.js ' . node_version.string . ' is end-of-life'
@@ -506,10 +510,10 @@ function! s:GetCapabilitiesError(error, agent) abort
506510
endfunction
507511

508512
function! s:AgentStartupError() dict abort
509-
while has_key(self, 'job') && !has_key(self, 'startup_error') && !has_key(self, 'capabilities')
513+
while (has_key(self, 'job') || has_key(self, 'client_id')) && !has_key(self, 'startup_error') && !has_key(self, 'capabilities')
510514
sleep 10m
511515
endwhile
512-
if has_key(self, 'capabilities') || has_key(self, 'client_id')
516+
if has_key(self, 'capabilities')
513517
return ''
514518
else
515519
return get(self, 'startup_error', 'Something unexpected went wrong spawning the agent')

autoload/copilot/logger.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -51,7 +51,7 @@ function! copilot#logger#Error(...) abort
5151
endfunction
5252

5353
function! copilot#logger#Exception() abort
54-
if !empty(v:exception)
54+
if !empty(v:exception) && v:exception !=# 'Vim:Interrupt'
5555
call copilot#logger#Error('Exception: ' . v:exception . ' @ ' . v:throwpoint)
5656
let agent = copilot#RunningAgent()
5757
if !empty(agent)

dist/agent.js

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

dist/agent.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: 3 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -23,7 +23,9 @@ copilot.lsp_start_client = function(cmd, handler_names)
2323
vim.call('copilot#agent#LspInit', client.id, initialize_result)
2424
end,
2525
on_exit = function(code, signal, client_id)
26-
vim.call('copilot#agent#LspExit', client_id, code, signal)
26+
vim.schedule(function()
27+
vim.call('copilot#agent#LspExit', client_id, code, signal)
28+
end)
2729
end
2830
})
2931
return id

0 commit comments

Comments
 (0)