Skip to content

Commit 315c6d2

Browse files
committed
Copilot.vim 1.18.0
1 parent 22fd954 commit 315c6d2

File tree

6 files changed

+395
-272
lines changed

6 files changed

+395
-272
lines changed

autoload/copilot.vim

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -226,7 +226,7 @@ function! s:SuggestionTextWithAdjustments() abort
226226
endif
227227
let line = getline('.')
228228
let offset = col('.') - 1
229-
let choice_text = strpart(line, 0, copilot#doc#UTF16ToByteIdx(line, choice.range.start.character)) . choice.text
229+
let choice_text = strpart(line, 0, copilot#doc#UTF16ToByteIdx(line, choice.range.start.character)) . substitute(choice.text, "\n*$", '', '')
230230
let typed = strpart(line, 0, offset)
231231
let end_offset = copilot#doc#UTF16ToByteIdx(line, choice.range.end.character)
232232
if end_offset < 0

autoload/copilot/agent.vim

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -151,7 +151,7 @@ function! s:BufferText(bufnr) abort
151151
endfunction
152152

153153
function! s:LogMessage(params) abort
154-
call copilot#logger#Raw(get(a:params, 'level', 3), get(a:params, 'message', ''))
154+
call copilot#logger#Raw(get(a:params, 'type', 6), get(a:params, 'message', ''))
155155
endfunction
156156

157157
function! s:ShowMessageRequest(params) abort
@@ -294,7 +294,9 @@ function! s:OnResponse(agent, response, ...) abort
294294
endfunction
295295

296296
function! s:OnErr(agent, line, ...) abort
297-
call copilot#logger#Debug('<-! ' . a:line)
297+
if !has_key(a:agent, 'capabilities')
298+
call copilot#logger#Bare('<-! ' . a:line)
299+
endif
298300
endfunction
299301

300302
function! s:OnExit(agent, code, ...) abort
@@ -508,7 +510,6 @@ function! copilot#agent#New(...) abort
508510
\ 'StartupError': function('s:AgentStartupError'),
509511
\ }
510512
let instance.methods = extend({
511-
\ 'LogMessage': function('s:LogMessage'),
512513
\ 'window/logMessage': function('s:LogMessage'),
513514
\ }, get(opts, 'methods', {}))
514515
let [command, node_version, command_error] = s:Command()

autoload/copilot/logger.vim

Lines changed: 12 additions & 5 deletions
Original file line numberDiff line numberDiff line change
@@ -10,11 +10,14 @@ function! copilot#logger#File() abort
1010
return s:log_file
1111
endfunction
1212

13+
let s:level_prefixes = ['', '[ERROR] ', '[WARN] ', '[INFO] ', '[DEBUG] ', '[TRACE] ']
14+
1315
function! copilot#logger#Raw(level, message) abort
14-
if $COPILOT_AGENT_VERBOSE !~# '^\%(1\|true\)$' && a:level < 1
16+
if $COPILOT_AGENT_VERBOSE !~# '^\%(1\|true\)$' && a:level > 3
1517
return
1618
endif
1719
let lines = type(a:message) == v:t_list ? copy(a:message) : split(a:message, "\n", 1)
20+
let lines[0] = strftime('[%Y-%m-%dT%H:%M:%S] ') . get(s:level_prefixes, a:level, '[UNKNOWN] ') . get(lines, 0, '')
1821
try
1922
if !filewritable(s:log_file)
2023
return
@@ -26,23 +29,27 @@ function! copilot#logger#Raw(level, message) abort
2629
endfunction
2730

2831
function! copilot#logger#Trace(...) abort
29-
call copilot#logger#Raw(-1, a:000)
32+
call copilot#logger#Raw(5, a:000)
3033
endfunction
3134

3235
function! copilot#logger#Debug(...) abort
33-
call copilot#logger#Raw(0, a:000)
36+
call copilot#logger#Raw(4, a:000)
3437
endfunction
3538

3639
function! copilot#logger#Info(...) abort
37-
call copilot#logger#Raw(1, a:000)
40+
call copilot#logger#Raw(3, a:000)
3841
endfunction
3942

4043
function! copilot#logger#Warn(...) abort
4144
call copilot#logger#Raw(2, a:000)
4245
endfunction
4346

4447
function! copilot#logger#Error(...) abort
45-
call copilot#logger#Raw(3, a:000)
48+
call copilot#logger#Raw(1, a:000)
49+
endfunction
50+
51+
function! copilot#logger#Bare(...) abort
52+
call copilot#logger#Raw(0, a:000)
4653
endfunction
4754

4855
function! copilot#logger#Exception(...) abort

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.17.0'
2+
return '1.18.0'
33
endfunction

dist/agent.js

Lines changed: 374 additions & 259 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)