Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Merged #3617 breaks UltiSnips placeholder mechanism #3625

Closed
dunric opened this issue Jan 1, 2024 · 3 comments · Fixed by #3626
Closed

Merged #3617 breaks UltiSnips placeholder mechanism #3625

dunric opened this issue Jan 1, 2024 · 3 comments · Fixed by #3626
Labels

Comments

@dunric
Copy link

dunric commented Jan 1, 2024

It seems merged PR #3617 breaks code completion for function placeholders.

I had to roll back to preceding commit to make it work again.

After the PR, using code completion at function's argument placeholder (provided by UltiSnips), a selected identifier is inserted including its previously typed-in prefix.

For example, create a variable sample := []int{1,2,3} . Then later attempt to put it in a function argument using code completion, at a placeholder position invoke omni-completion menu, type leading three chars sam and select sample identifier - results in following

fmt.Println(samsample)
            ^^^
@bhcleek
Copy link
Collaborator

bhcleek commented Jan 2, 2024

I'm not able to replicate any changes in behavior between #3617 and master before it was merged. Perhaps your 'completeopt' setting may be useful. What do you have for it?

@timesselens
Copy link

I'm seeing this as well, bisected to commit 3c223ad

might it be an off-by-one in autoload/go/lsp/lsp.vim:12 ?
return [l:line - 1, s:character(l:line, l:col-1)] vs return [l:line - 1, s:character(l:line, l:col)]

I rolled back because my ultisnips contains a "macro" for printf

global !p
  def echo_vals(t, placeholder="%+v"):
     return ', '.join(["%s: %s" % (a.strip(), placeholder) for a in
        t[1].split(',') if len(a.strip())])
endglobal

which is then used inside the snippet:

  snippet p "printf" b
  fmt.Printf("${2}`!p snip.rv = echo_vals(t)`\n", ${1})
  endsnippet

I could not complete at the placeholder anymore, all context seems to be lost.
I've only looked at it briefly but from the GoLspDebugBrowser output it seems that there is some kind of line/col mismatch as the debugger showed something about the line not having so many cols. First I assumed it was a line number off by one. Didn't investigate fully at that time.

completeopt=menuone,noinsert,noselect

@bhcleek
Copy link
Collaborator

bhcleek commented Jan 4, 2024

Thank you, @timesselens. I can duplicate this now and see that it was working prior to #3617.

@bhcleek bhcleek added the bug label Jan 4, 2024
bhcleek added a commit to bhcleek/vim-go that referenced this issue Jan 4, 2024
Fix off by one in column calculation introduced in fatih#3617.

Fixes fatih#3625
bhcleek added a commit to bhcleek/vim-go that referenced this issue Jan 6, 2024
Fix off by one in column calculation introduced in fatih#3617.

Fixes fatih#3625
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

Successfully merging a pull request may close this issue.

3 participants