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

Completion (and renaming) behaves incorrectly on labels with colons #30

Closed
clason opened this issue Jun 27, 2019 · 2 comments
Closed

Completion (and renaming) behaves incorrectly on labels with colons #30

clason opened this issue Jun 27, 2019 · 2 comments
Assignees
Labels
bug Something isn't working

Comments

@clason
Copy link
Contributor

clason commented Jun 27, 2019

Completion on symbols that include colons (such as eq:strong-convergence) can lead to incorrect substitutions. I've originally reported this for vim-lsp (prabirshrestha/vim-lsp#420), but it turns out the issue occurs in VS Code as well (slightly differently).

Here's a minimal example from @thomasfaingnaert:

documentclass{article}

\begin{document}
\section{Foo bar}%
\label{sec:foo_bar}
\ref{sec:foo<cursor here>}
\end{document}

The language server then correctly suggests sec:foo_bar, but when I select it, it inserts it after the initial sec:, i.e., I get sec:sec:foo_bar. (vim-lsp turns that into \ref{sec:barsec:foo_bar} instead.)

The relevant part of the log is

Thu 27 Jun 2019 15:19:36 CEST:["--->",1,"texlab",{"method":"textDocument/completion","on_notification":"---funcref---","params":{"textDocument":{"uri":"file:///home/thomas/test.tex"},"position":{"character":12,"line":5}}}]
Thu 27 Jun 2019 15:19:36 CEST:["<---",1,"texlab",{"response":{"id":41,"jsonrpc":"2.0","result":{"isIncomplete":true,"items":[{"label":"sec:foo_bar","data":"Label","kind":5}]}},"request":{"id":41,"jsonrpc":"2.0","method":"textDocument/completion","params":{"textDocument":{"uri":"file:///home/thomas/test.tex"},"position":{"character":12,"line":5}}}}]

i.e., texlab gives the wrong position. (A related issue is with renaming: if I rename sec:foo_bar, the prefilled text is just foo_bar, but the whole label (including sec:) is replaced with what I write. This is much less critical, of course.)

@thomasfaingnaert suggests not using labels for completions but rather text-edits, which is a newer part of the LSP protocol.

@pfoerster pfoerster self-assigned this Jun 27, 2019
@pfoerster pfoerster added the bug Something isn't working label Jun 27, 2019
@pfoerster
Copy link
Member

@thomasfaingnaert suggests not using labels for completions but rather text-edits, which is a newer part of the LSP protocol.

The server now uses the textEdit field in CompletionItem.
In your example, the completion now works correctly.

(A related issue is with renaming: if I rename sec:foo_bar, the prefilled text is just foo_bar, but the whole label (including sec:) is replaced with what I write. This is much less critical, of course.)

The server now implements the textEdit/prepareRename request so this issue should be fixed as well.

@clason
Copy link
Contributor Author

clason commented Jul 1, 2019

Great, thanks!

@clason clason closed this as completed Jul 1, 2019
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

2 participants