Skip to content

Commit 5a411d1

Browse files
committed
Copilot.vim 1.6.1
1 parent 8ba151a commit 5a411d1

File tree

5 files changed

+30
-10
lines changed

5 files changed

+30
-10
lines changed

.gitattributes

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1 +1,2 @@
1+
*.vim eol=lf
12
/copilot/dist/* -whitespace -diff

autoload/copilot.vim

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -71,6 +71,14 @@ function! copilot#Agent() abort
7171
return s:agent
7272
endfunction
7373

74+
function! copilot#RunningAgent() abort
75+
if s:Running()
76+
return s:agent
77+
else
78+
return v:null
79+
endif
80+
endfunction
81+
7482
function! copilot#Request(method, params, ...) abort
7583
let agent = copilot#Agent()
7684
return call(agent.Request, [a:method, a:params] + a:000)

autoload/copilot/agent.vim

Lines changed: 7 additions & 8 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.6.0'
8+
let s:plugin_version = '1.6.1'
99

1010
let s:error_exit = -1
1111

@@ -166,11 +166,7 @@ endfunction
166166

167167
function! s:OnMessage(agent, body, ...) abort
168168
call copilot#logger#Trace({ -> '<-- ' . a:body})
169-
try
170-
let response = json_decode(a:body)
171-
catch
172-
return copilot#logger#Exception()
173-
endtry
169+
let response = json_decode(a:body)
174170
if type(response) != v:t_dict
175171
return
176172
endif
@@ -314,6 +310,7 @@ function! s:LspRequest(method, params, ...) dict abort
314310
endif
315311
if has_key(self, 'client_id')
316312
call copilot#agent#LspExit(self.client_id, -1, -1)
313+
unlet! self.client_id
317314
endif
318315
throw 'copilot#agent: LSP client not available'
319316
endfunction
@@ -371,7 +368,7 @@ function! s:Command() abort
371368
let err = []
372369
let status = copilot#job#Stream(node + ['--version'], function('add', [out]), function('add', [err]))
373370
if status != 0
374-
return [v:null, 'Node.js exited with status ' . status]
371+
return [v:null, '', 'Node.js exited with status ' . status]
375372
endif
376373
let node_version = matchstr(join(out, ''), '^v\zs\d\+\.[^[:space:]]*')
377374
let major = str2nr(node_version)
@@ -428,7 +425,9 @@ endfunction
428425

429426
function! s:GetCapabilitiesResult(result, agent) abort
430427
let a:agent.capabilities = get(a:result, 'capabilities', {})
431-
call a:agent.Request('setEditorInfo', extend({'editorConfiguration': a:agent.editorConfiguration}, copilot#agent#EditorInfo()))
428+
let info = deepcopy(copilot#agent#EditorInfo())
429+
let info.editorInfo.version .= ' + Node.js ' . a:agent.node_version
430+
call a:agent.Request('setEditorInfo', extend({'editorConfiguration': a:agent.editorConfiguration}, info))
432431
endfunction
433432

434433
function! s:GetCapabilitiesError(error, agent) abort

autoload/copilot/logger.vim

Lines changed: 12 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -53,5 +53,17 @@ endfunction
5353
function! copilot#logger#Exception() abort
5454
if !empty(v:exception)
5555
call copilot#logger#Error('Exception: ' . v:exception . ' @ ' . v:throwpoint)
56+
let agent = copilot#RunningAgent()
57+
if !empty(agent)
58+
if v:throwpoint =~# '[\/]'
59+
let throwpoint = '[redacted]'
60+
else
61+
let throwpoint = v:throwpoint
62+
endif
63+
call agent.Request('telemetry/exception', {
64+
\ 'origin': 'copilot.vim',
65+
\ 'stacktrace': v:exception . ' @ ' . throwpoint,
66+
\ })
67+
endif
5668
endif
5769
endfunction

copilot/dist/agent.js

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

0 commit comments

Comments
 (0)