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

Issues when buffer contains special characters #124

Closed
mkcms opened this issue Oct 3, 2018 · 0 comments
Closed

Issues when buffer contains special characters #124

mkcms opened this issue Oct 3, 2018 · 0 comments
Labels

Comments

@mkcms
Copy link
Collaborator

mkcms commented Oct 3, 2018

Using clangd:

  1. Find a C++ file with these contents and enable eglot there:
int main()
{
    float circle_area(float, float = 3.14 /*=𝛱*/); circle_are(5);
}
  1. The misspelled call to circle_are is highlighted, calling eglot-code-actions on this diagnostic and applying a fix results in:
int main()
{
    float circle_area(float, float = 3.14 /*=𝛱*/); ccircle_area5);
}
@mkcms mkcms added the bug label Nov 7, 2018
joaotavora added a commit that referenced this issue Nov 7, 2018
* eglot-tests.el (issue-124): New test.

* eglot.el (eglot--lsp-char-to-column): New helper.
(eglot--lsp-position-to-point): Use eglot--lsp-char-to-column.

* fixtures/utf16.cpp: New test fixture
joaotavora added a commit that referenced this issue Nov 8, 2018
* eglot-tests.el (issue-124): New test.

* eglot.el (eglot--lsp-char-to-column): New helper.
(eglot--lsp-position-to-point): Use eglot--lsp-char-to-column.

* fixtures/utf16.cpp: New test fixture
mkcms added a commit that referenced this issue Nov 11, 2018
The spec says that :character offsets are based on a UTF-16
representation.  Previously we were assuming that :character specifies
the number of characters.

* eglot.el (eglot-full-position-conversion): New defvar.
(eglot--count-characters): New function.
(eglot--pos-to-lsp-position):
(eglot--lsp-position-to-point): Use it.
bhankas pushed a commit to bhankas/emacs that referenced this issue Sep 18, 2022
Also close joaotavora/eglot#125.

Idea and much of design contributed by Michał Krzywkowski
<[email protected]>

This introduces the variable eglot-move-to-column-function.

According to the standard, LSP column/character offsets are based
on a count of UTF-16 code units, not actual visual columns.  So
when LSP says position 3 of a line containing just \"aXbc\",
where X is a multi-byte character, it actually means `b', not
`c'.  This is what the function
`eglot-move-to-lsp-abiding-column' does.

However, many servers don't follow the spec this closely, and
thus this variable should be set to `move-to-column' in buffers
managed by those servers.

* eglot.el (eglot-move-to-column-function): New variable.
(eglot-move-to-lsp-abiding-column): New function.
(eglot--lsp-position-to-point): Use eglot-move-to-column-function.
bhankas pushed a commit to bhankas/emacs that referenced this issue Sep 19, 2022
Also close joaotavora/eglot#125.

Idea and much of design contributed by Michał Krzywkowski
<[email protected]>

This introduces the variable eglot-move-to-column-function.

According to the standard, LSP column/character offsets are based
on a count of UTF-16 code units, not actual visual columns.  So
when LSP says position 3 of a line containing just \"aXbc\",
where X is a multi-byte character, it actually means `b', not
`c'.  This is what the function
`eglot-move-to-lsp-abiding-column' does.

However, many servers don't follow the spec this closely, and
thus this variable should be set to `move-to-column' in buffers
managed by those servers.

* eglot.el (eglot-move-to-column-function): New variable.
(eglot-move-to-lsp-abiding-column): New function.
(eglot--lsp-position-to-point): Use eglot-move-to-column-function.
bhankas pushed a commit to bhankas/emacs that referenced this issue Sep 19, 2022
Also close #125.

Idea and much of design contributed by Michał Krzywkowski
<[email protected]>

This introduces the variable eglot-move-to-column-function.

According to the standard, LSP column/character offsets are based
on a count of UTF-16 code units, not actual visual columns.  So
when LSP says position 3 of a line containing just \"aXbc\",
where X is a multi-byte character, it actually means `b', not
`c'.  This is what the function
`eglot-move-to-lsp-abiding-column' does.

However, many servers don't follow the spec this closely, and
thus this variable should be set to `move-to-column' in buffers
managed by those servers.

* eglot.el (eglot-move-to-column-function): New variable.
(eglot-move-to-lsp-abiding-column): New function.
(eglot--lsp-position-to-point): Use eglot-move-to-column-function.

#124: joaotavora/eglot#124
#125: joaotavora/eglot#125
jollaitbot pushed a commit to sailfishos-mirror/emacs that referenced this issue Oct 12, 2022
Also close joaotavora/eglot#125.

Idea and much of design contributed by Michał Krzywkowski
<[email protected]>

This introduces the variable eglot-move-to-column-function.

According to the standard, LSP column/character offsets are based
on a count of UTF-16 code units, not actual visual columns.  So
when LSP says position 3 of a line containing just \"aXbc\",
where X is a multi-byte character, it actually means `b', not
`c'.  This is what the function
`eglot-move-to-lsp-abiding-column' does.

However, many servers don't follow the spec this closely, and
thus this variable should be set to `move-to-column' in buffers
managed by those servers.

* eglot.el (eglot-move-to-column-function): New variable.
(eglot-move-to-lsp-abiding-column): New function.
(eglot--lsp-position-to-point): Use eglot-move-to-column-function.

GitHub-reference: fix joaotavora/eglot#124
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
Projects
None yet
Development

No branches or pull requests

1 participant