Skip to content

Commit 7097b09

Browse files
committed
Copilot.vim 1.27.0
1 parent 9484e35 commit 7097b09

File tree

6 files changed

+623
-330
lines changed

6 files changed

+623
-330
lines changed

‎autoload/copilot.vim‎

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -187,7 +187,6 @@ endfunction
187187
function!copilot#Enabled() abort
188188
returnget(g:, 'copilot_enabled', 1)
189189
\ &&empty(s:BufferDisabled())
190-
\ &&empty(copilot#Agent().StartupError())
191190
endfunction
192191

193192
function!copilot#Complete(...) abort
@@ -362,7 +361,7 @@ function! s:UpdatePreview() abort
362361
endif
363362
let data.hl_mode ='combine'
364363
callnvim_buf_set_extmark(0, copilot#NvimNs(), line('.')-1, col('.')-1, data)
365-
else
364+
elseifs:has_vim_ghost_text
366365
callprop_add(line('.'), col('.'),{'type': s:hlgroup, 'text': text[0]})
367366
forlinein text[1:]
368367
callprop_add(line('.'), 0,{'type': s:hlgroup, 'text_align': 'below', 'text': line})
@@ -412,7 +411,7 @@ function! s:Trigger(bufnr, timer) abort
412411
endfunction
413412

414413
function!copilot#Schedule(...) abort
415-
if!s:has_ghost_text||!copilot#Enabled()
414+
if!s:has_ghost_text||!s:Running() ||!copilot#Enabled()
416415
callcopilot#Clear()
417416
return
418417
endif

‎autoload/copilot/agent.vim‎

Lines changed: 1 addition & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -495,7 +495,7 @@ function! copilot#agent#EditorInfo() abort
495495
ifhas('nvim')
496496
lets:editor_version=matchstr(execute('version'), 'NVIM v\zs[^[:space:]]\+')
497497
else
498-
lets:editor_version= (v:version / 100) . '.' . (v:version%100) . (exists('v:versionlong') ? printf('.%04d', v:versionlong%1000) : '')
498+
lets:editor_version= (v:version / 100) . '.' . (v:version%100) . (exists('v:versionlong') ? printf('.%04d', v:versionlong%10000) : '')
499499
endif
500500
endif
501501
return{'name': has('nvim') ? 'Neovim': 'Vim', 'version': s:editor_version}
@@ -557,7 +557,6 @@ function! s:AgentStartupError() dict abort
557557
endfunction
558558

559559
function!s:StatusNotification(params, agent) abort
560-
callcopilot#logger#Info('StatusNotification ' . string(a:params))
561560
leta:agent.status =a:params
562561
endfunction
563562

‎autoload/copilot/panel.vim‎

Lines changed: 17 additions & 11 deletions
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ endif
77
lets:separator=repeat('', 72)
88

99
function!s:Solutions(state) abort
10-
returnsort(values(get(a:state, 'solutions',{})),{a, b-> a.score<b.score })
10+
returnsort(values(get(a:state, 'solutions',{})),{a, b-> a.score !=b.score ? b.score -a.score : a._index -b._index })
1111
endfunction
1212

1313
function!s:Render(panel_id) abort
@@ -21,8 +21,8 @@ function! s:Render(panel_id) abort
2121
letlines= ['Error: ' . state.status]
2222
else
2323
let target =get(state, 'count_target', '?')
24-
let received =has_key(state, 'status') ? target : len(sorted)
25-
letlines= ['Synthesiz' . (has_key(state, 'status') ? 'ed ' : 'ing ') . received . '/' . target . 'solutions (Duplicates hidden)']
24+
let received =state.count_received
25+
letlines= ['Synthesiz' . (has_key(state, 'status') ? 'ed ' : 'ing ') . received . '/' . target . 'completions (Duplicates hidden)']
2626
endif
2727
iflen(sorted)
2828
calladd(lines, 'Press <CR> on a solution to accept')
@@ -44,7 +44,11 @@ function! copilot#panel#Solution(params, ...) abort
4444
if!bufloaded(a:params.panelId) ||type(state) !=v:t_dict
4545
return
4646
endif
47-
letstate.solutions[a:params.solutionId] =a:params
47+
letstate.count_received +=1
48+
if!has_key(state.solutions, a:params.solutionId) ||state.solutions[a:params.solutionId].score < a:params.score
49+
leta:params._index =state.count_received
50+
letstate.solutions[a:params.solutionId] =a:params
51+
endif
4852
calls:Render(a:params.panelId)
4953
endfunction
5054

@@ -78,12 +82,12 @@ function! copilot#panel#Accept(...) abort
7882
let solution = solutions[solution_index -1]
7983
let lnum = solution.range.start.line+1
8084
ifgetbufline(state.bufnr, lnum) !=# [state.line]
81-
return'echoerr "Buffer has changed since synthesizing solution"'
85+
return'echoerr "Buffer has changed since synthesizing completion"'
8286
endif
8387
letlines=split(solution.completionText, "\n", 1)
84-
let old_first =getline(solution.range.start.line+1)
88+
let old_first =getbufline(state.bufnr, solution.range.start.line+1)[0]
8589
letlines[0] =strpart(old_first, 0, copilot#doc#UTF16ToByteIdx(old_first, solution.range.start.character)) . lines[0]
86-
let old_last =getline(solution.range.end.line+1)
90+
let old_last =getbufline(state.bufnr, solution.range.end.line+1)[0]
8791
letlines[-1] .=strpart(old_last, copilot#doc#UTF16ToByteIdx(old_last, solution.range.start.character))
8892
callsetbufline(state.bufnr, solution.range.start.line+1, lines[0])
8993
callappendbufline(state.bufnr, solution.range.start.line+1, lines[1:-1])
@@ -126,16 +130,18 @@ endfunction
126130

127131
function!copilot#panel#Open(opts) abort
128132
lets:panel_id+=1
129-
letstate={'solutions':{}, 'filetype': &filetype, 'line': getline('.'), 'bufnr': bufnr(''), 'tabstop': &tabstop}
133+
letstate={'solutions':{}, 'filetype': &filetype, 'was_insert': mode() =~# '^[iR]', 'bufnr': bufnr(''), 'tabstop': &tabstop}
134+
letstate.line=getline(state.was_insert ? '.' : a:opts.line1)
130135
letbufname='copilot:///panel/' . s:panel_id
131136
let params =copilot#doc#Params({'panelId': bufname})
132-
letstate.was_insert =mode() =~# '^[iR]'
133137
ifstate.was_insert
134138
stopinsert
135139
else
136-
let params.doc.position.character=copilot#doc#UTF16Width(state.line)
137-
let params.position.character=params.doc.position.character
140+
let params.position.line=a:opts.line1 > 0 ? a:opts.line1 -1 : 0
141+
let params.position.character=copilot#doc#UTF16Width(state.line)
138142
endif
143+
let params.doc.position = params.position
144+
letstate.count_received =0
139145
let response =copilot#Request('getPanelCompletions', params).Wait()
140146
if response.status ==# 'error'
141147
return'echoerr ' . string(response.error.message)

‎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.26.0'
2+
return'1.27.0'
33
endfunction

‎dist/agent.js‎

Lines changed: 599 additions & 310 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.

0 commit comments

Comments
(0)