Skip to content

Commit

Permalink
fix(snippet): deviation in snippet select in the first column (#5104)
Browse files Browse the repository at this point in the history
  • Loading branch information
A4-Tacks authored Aug 28, 2024
1 parent 0e6a8c7 commit 53e21a9
Show file tree
Hide file tree
Showing 2 changed files with 4 additions and 4 deletions.
6 changes: 3 additions & 3 deletions autoload/coc/snippet.vim
Original file line number Diff line number Diff line change
Expand Up @@ -109,7 +109,7 @@ function! coc#snippet#select(start, end, text) abort
if coc#pum#visible()
call coc#pum#close()
endif
if mode() == 's'
if mode() ==? 's'
call feedkeys("\<Esc>", 'in')
endif
if &selection ==# 'exclusive'
Expand All @@ -124,7 +124,7 @@ function! coc#snippet#select(start, end, text) abort
call cursor([cursor[0], cursor[1] - 1])
let len = strchars(a:text) - 1
let cmd = ''
let cmd .= mode()[0] ==# 'i' ? "\<Esc>l" : ''
let cmd .= mode()[0] ==# 'i' ? "\<Esc>".(col('.') == 1 ? '' : 'l') : ''
let cmd .= printf('v%s', len > 0 ? len . 'h' : '')
let cmd .= "o\<C-g>"
endif
Expand All @@ -133,7 +133,7 @@ endfunction

function! coc#snippet#move(position) abort
let m = mode()
if m == 's'
if m ==? 's'
call feedkeys("\<Esc>", 'in')
endif
let pos = coc#snippet#to_cursor(a:position)
Expand Down
2 changes: 1 addition & 1 deletion src/__tests__/snippets/session.test.ts
Original file line number Diff line number Diff line change
Expand Up @@ -187,7 +187,7 @@ describe('SnippetSession', () => {
res = await session.start('${1:foo} ${2:bar}', r, false)
expect(res).toBe(true)
line = await nvim.line
expect(line).toBe('afoo bar b')
expect(line).toBe('foo bara b')
})

it('should not nested when range not contains', async () => {
Expand Down

0 comments on commit 53e21a9

Please sign in to comment.