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

C_Cpp.SwitchHeaderSource does not work anymore #541

Closed
1100101 opened this issue Mar 9, 2017 · 17 comments
Closed

C_Cpp.SwitchHeaderSource does not work anymore #541

1100101 opened this issue Mar 9, 2017 · 17 comments
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service

Comments

@1100101
Copy link

1100101 commented Mar 9, 2017

After opening a .cpp or .hpp file, switching to the respective other file via Alt+O does not work anymore.
Both files are located in the same folder, next to each other.
Source file extension: .cpp
Header file extension: .hpp

Pressing Ctrl+Shift+P and selecting "Switch header/source" does not work either.

  • VSCode Version: Code 1.10.2 (8076a19fdcab7e1fc1707952d652f0bb6c6db331, 2017-03-08T14:02:52.799Z)
  • OS Version: Windows_NT ia32 6.1.7601
  • Extensions:
Extension Author Version
FreeMarker dcortes92 0.0.8
vscode-yaml-validation djabraham 0.0.1
xml DotJoshJohnson 1.7.0
cpptools ms-vscode 0.10.2
diff rafaelmaiolla 0.0.1
missinglineendoffile riccardoNovaglia 0.1.6
annotator ryu1kn 0.10.1
partial-diff ryu1kn 0.2.0
trailing-spaces shardulm94 0.2.11
scope-info siegebell 0.2.0
indenticator SirTori 0.2.1
theme-visualstudio none 0.0.1
theme-visualstudio-2016 none 0.0.1
tmlanguage Togusa09 0.7.1

Steps to Reproduce:

  1. Put two files MyClass.hpp + MyClass.cpp in a folder
  2. Open a file named MyClass.hpp
  3. Press Alt+O to switch to MyClass.cpp

The file MyClass.cpp is not opened.

@sean-mcmanus
Copy link
Collaborator

I'm not able to repro the bug. I suspect another extension is interfering by having another Alt+O command. You can also try right-clicking ad selecting the Switch Header/Source option. Can you repro the bug with the other extensions disabled?

@sean-mcmanus sean-mcmanus added the more info needed The issue report is not actionable in its current state label Mar 9, 2017
@dacap
Copy link

dacap commented Mar 10, 2017

I'm suffering this same issue. In my case the language service crashes 3 times or 5 (I'm not sure) and a message popup at the top saying that the service wasn't going to be restarted again. Is there a way to restart the language service? Can I share some information that might be useful to you? (e.g. a crash log/memory dump?)

@1100101
Copy link
Author

1100101 commented Mar 10, 2017

I just installed Visual Studio Code (stable) on a different machine (Windows 10 this time).
The app was never installed on this PC before.
Installed just the C++ extension, created two files MyClass.hpp and MyClass.cpp.
Switching between them by pressing Alt+o does not work.
Right-clicking and selecting "Switch header/source" does nothing.

Is there any console or log where I might see a warning or error message?

@bobbrow
Copy link
Member

bobbrow commented Mar 10, 2017

Have you explicitly opened a folder, or just the individual files? Many of our extension's features are expecting you to open a folder first. This defines the ${workspaceRoot} variable among other things.

We'll add a backlog item to display some sort of message if you try to use a feature that depends on a folder being open.

open folder

@1100101
Copy link
Author

1100101 commented Mar 10, 2017

I just opened individual files, not a folder.
But that feature worked just fine that way until recently, without opening a folder.

@sean-mcmanus
Copy link
Collaborator

We changed the implementation to require the browse database. Is there a reason you don't open the folder the file is in instead? The open file scenario has been low priority for us, so lots of features don't work with it. It's possible we could get it working though.

@1100101
Copy link
Author

1100101 commented Mar 10, 2017

Well, I primarily use Visual Studio (the IDE) for development. But since I have to work with many C++ projects, I often use VS Code to look up something in a specific file that is currently not loaded in a Visual Studio instance.
With C++ the need for switching between header and source is self-explanatory.

I'd very much appreciate it if that feature would work without opening a folder again.

@dacap
Copy link

dacap commented Mar 10, 2017

Maybe related, I think this feature should work in a simple way: 1) check if there is a file with the same title but with the other extension in the same directory, 2) if that is not the case and we have a folder open, use the new logic. Here is an example about some weird behavior when there are several candidates for the same .h/.cpp file:

invalid-other-file

Instead of selecting the obvious option src/ui/graphics.cpp first, the extension opens src/allegro/src/graphics.c and then switch between src/allegro/include/allegro/graphics.h and src/allegro/src/graphics.c.

@sean-mcmanus
Copy link
Collaborator

@1100101 Sure, since it's a regression in previous behavior we'll increase the priority.
@dacap That is a bug. Thanks for a repro. It's supposed to select the header/source in the same folder first.

@bobbrow bobbrow added bug and removed more info needed The issue report is not actionable in its current state labels Mar 10, 2017
@sean-mcmanus
Copy link
Collaborator

@dacap If you're getting a crash, can you attach a debugger and get a dmp? We're still trying to figure out why we're not getting any crash dmps on Windows.

@dacap
Copy link

dacap commented Mar 10, 2017

@sean-mcmanus In my case, I'm on macOS, I've several Microsoft.VSCode.CPP.Extension.darwin_2017-03-10...crash files. Is there a place/email address where I can send/upload these files?

@sean-mcmanus
Copy link
Collaborator

Can you email them to c_cpp_support@microsoft.com ?

@dacap
Copy link

dacap commented Mar 11, 2017

I've just sent them, I hope it helps!

@bobbrow
Copy link
Member

bobbrow commented Mar 15, 2017

We just released 0.10.4 with some improvements for switch header/source. Can you install the update and let us know if we've resolved your issues?

@bobbrow bobbrow added the fixed Check the Milestone for the release in which the fix is or will be available. label Mar 15, 2017
@1100101
Copy link
Author

1100101 commented Mar 16, 2017

Yes, the issue is fixed with the latest version.
Thanks!

@ArtyMcLabin
Copy link

I have this problem in 2018.
My .h files are in "${workspaceRoot}/Proj/Public",
.cpp files are in "${workspaceRoot}/Proj/Private",

can't switch by either Alt+O or right click menu.

both these folders exist in browse.path and includePath of c_cpp_properties.json

Any clues?

@sayo9394
Copy link

I have this problem in 2018.
My .h files are in "${workspaceRoot}/Proj/Public",
.cpp files are in "${workspaceRoot}/Proj/Private",

can't switch by either Alt+O or right click menu.

both these folders exist in browse.path and includePath of c_cpp_properties.json

Any clues?

Same here, I have the same, unable to switch header/source, with version 1.32.2 on Windows 10.
the VSCode setup on ubuntu doesn't have this issue.
Cheers.

@github-actions github-actions bot locked and limited conversation to collaborators Oct 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug fixed Check the Milestone for the release in which the fix is or will be available. Language Service
Projects
None yet
Development

No branches or pull requests

6 participants