Skip to content

Commit

Permalink
Fixed: deviation in snippet select in the first column
Browse files Browse the repository at this point in the history
  • Loading branch information
A4-Tacks committed Aug 5, 2024
1 parent c5ffbb3 commit 2341057
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 2341057

Please sign in to comment.