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

highlighting gets column wrong in tab-indented code (clangd / ccls) #200

Closed
haphi opened this issue Jan 8, 2019 · 5 comments
Closed

highlighting gets column wrong in tab-indented code (clangd / ccls) #200

haphi opened this issue Jan 8, 2019 · 5 comments

Comments

@haphi
Copy link

haphi commented Jan 8, 2019

Hello,
I happily use eglot (1.4 from MELPA) with ccls-7.0.1 and noticed that the highlighted region for symbols is not correct in tab-indented files (all ASCII), it is shifted to the left by the number of tabs preceding the region. The same happens when using clangd -7.0.1. I have not tested other language servers.

Reading a bit through the eglot sources, I found that setting the eglot-move-to-column-function to 'eglot-move-to-lsp-abiding-column solves the problem for me, by correctly converting lsp column values to emacs column values.

Is this a problem of eglot or should ccls/clangd behave differently?
Should this configuration be documented, or event made default for ccls/clangd servers?
Thanks!

@joaotavora
Copy link
Owner

I can't reproduce this with a simple dummy file and a fresh Eglot installation without the setting eglot-move-to-lsp-abiding-column.

Here's the file I tried

int bar();

int foo (){
  if (1) {
    return 1;
  } else {
    if (1) {
      if (1) {
	if (1) {
	  return bar();
	}
      } else
        return 2;
    }
  }
  return 0;
}



int main(int argc, char* argv[]){
  return 0;
}

There are some tabs in the deepest levels of foo. When I but my cursor on int bar the correct bar inside foo gets highlighted.

Can you give me a simple test file and a recipe for reproducing this starting with Emacs -Q?

Note: setting eglot-move-to-column-function to 'eglot-move-to-lsp-abiding-column is the right thing to do. It will eventually become the default. The reason it isn't yet is that many servers don't follow the spec fully regarding of UTF16 character encoding (see issue #125) But a tab character is an ASCII character so it shouldn't have any influence here.

@haphi
Copy link
Author

haphi commented Jan 10, 2019

Well this is embarrassing, I can't reproduce it with emacs -Q either.

I'll try to find out which part of my configuration causes this and will let you know!

Sorry to waste your time...

@haphi haphi closed this as completed Jan 10, 2019
@joaotavora
Copy link
Owner

Are you setting tab-width anywhere in your configuration?

@haphi
Copy link
Author

haphi commented Jan 10, 2019

yes, I set it to 8
update: but changing it has no effect on the issue

@haphi
Copy link
Author

haphi commented Jan 10, 2019

Aha! It appears whitespace-mode is the culprit, I could reproduce the problem by running emacs -Q. Toggling whitespace-mode also causes the offset.

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

No branches or pull requests

2 participants