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

Toggle between source and header is not working when header not in source folder #237

Open
EmergReanimator opened this issue Jan 20, 2024 · 9 comments
Labels
bug Something isn't working

Comments

@EmergReanimator
Copy link

Toggle Source/Header command (Ctrl+Tab) is not supported by LSP editor

image

@ghentschke
Copy link
Contributor

It is supported. Please try Ctrl + Tab or check the context menu. There should be an entry: Toggle Source/Header

@EmergReanimator
Copy link
Author

EmergReanimator commented Jan 21, 2024

I figured out under which conditions the toggling does not cause the editor window switch:

If the code in .cpp file is inactive, then no switch happens as expected.

image

@EmergReanimator
Copy link
Author

Seems to be relevant to #234

@ghentschke
Copy link
Contributor

ghentschke commented Jan 21, 2024

It's rather a clangd than a cdt-lsp problem. You can check that, when enabling the LS console in Eclipse:

[2024-01-21T11:53:13.814455900+01:00] LSP4E_TO_LANGUAGE_SERVER org.eclipse.cdt.lsp.server:
{"jsonrpc":"2.0","id":"70","method":"textDocument/switchSourceHeader","params":{"uri":"file:/C:/Users/ghent/cdt-main/runtime-New_configuration/EmptyCmake/Cmk1.cpp"}}

[2024-01-21T11:53:13.815455200+01:00] LANGUAGE_SERVER_TO_LSP4E org.eclipse.cdt.lsp.server:
{
  "id": "70",
  "jsonrpc": "2.0",
  "result": null
}

The reponse returns null.
It works, when the header file is in the same directory as the source file. That should have already been fixed in clangd: see #182

@EmergReanimator
Copy link
Author

It's rather a clangd than a cdt-lsp problem. You can check that, when enabling the LS console in Eclipse:

[2024-01-21T11:53:13.814455900+01:00] LSP4E_TO_LANGUAGE_SERVER org.eclipse.cdt.lsp.server:
{"jsonrpc":"2.0","id":"70","method":"textDocument/switchSourceHeader","params":{"uri":"file:/C:/Users/ghent/cdt-main/runtime-New_configuration/EmptyCmake/Cmk1.cpp"}}

[2024-01-21T11:53:13.815455200+01:00] LANGUAGE_SERVER_TO_LSP4E org.eclipse.cdt.lsp.server:
{
  "id": "70",
  "jsonrpc": "2.0",
  "result": null
}

The null-result is returned in my environment too.

[2024-01-21T15:10:28.968150947+01:00] LSP4E_TO_LANGUAGE_SERVER org.eclipse.cdt.lsp.server:
{"jsonrpc":"2.0","id":"50","method":"textDocument/switchSourceHeader","params":{"uri":"file:/work/workspaces/rust/cdt_lsp_test/src/test.cpp"}}

[2024-01-21T15:10:28.968420615+01:00] LANGUAGE_SERVER_TO_LSP4E org.eclipse.cdt.lsp.server:
{
"id": "50",
"jsonrpc": "2.0",
"result": null
}

The reponse returns null. It works, when the header file is in the same directory as the source file. That should have already been fixed in clangd: see #182

Yes, indeed. I am using clangd version 17.0.6 (Fedora 17.0.6-1.fc39).
Should I submit this issue to clangd project?

@ghentschke
Copy link
Contributor

Should I submit this issue to clangd project?

yes, that would be fine. Thank you for your feedback on cdt-lsp!

@ghentschke ghentschke changed the title Switching between source code and header is not supported Switching between source code and header not in source path is not supported Jan 21, 2024
@ghentschke ghentschke changed the title Switching between source code and header not in source path is not supported Switching between source code and header not in source path is not working Jan 21, 2024
@ghentschke ghentschke added the bug Something isn't working label Jan 21, 2024
@ghentschke ghentschke changed the title Switching between source code and header not in source path is not working Toggle between source and header is not working when header not in source folder Jan 21, 2024
@EmergReanimator
Copy link
Author

Should I submit this issue to clangd project?

yes, that would be fine. Thank you for your feedback on cdt-lsp!

Does this report have anything in common with the current issue?

@ghentschke
Copy link
Contributor

Does this clangd/clangd#1575 have anything in common with the current issue?

No, not really.

@EmergReanimator
Copy link
Author

@ghentschke I believe this is the right one: Switch between header/source doesn't find correct file in trivial cases

I agree, I think a file index and using heuristics based on that would handle situations like this much better overall. Care would need to be taken if there's multiple files with the same name, though, ideally ties would be broken based on more similar paths. (e.g. if multiple internal projects with a Foo.h and Foo.cpp pair, one heuristic could be to match the companion that has the fewest directories to a common root)

These guys have 600+ open issue. I don't want to create even more buzz before they managed to reduce the number of issue to reasonable amount.

Let wait for some time for improved heuristics.

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