Closed RonnieLyu closed 5 years ago
I don't understand how to repro your issue. When I use Go to Def (Ctrl+Click) it opens a new document, unless the document is in preview mode, which can be disabled via the workbench.editor.enablePreview setting.
When I use Def (Ctrl+Click ), it does not open a new document, but the current file is modified. the workbench.editor.enablePreview setting was disabled .
This may happen only in Chinese. It‘s all right in English (ps:"locale":"en" ).
This may happen only in Chinese (ps:"locale":"zh-cn" ). It‘s all right in English (ps:"locale":"en" ).
Hmm, I installed the Chinese language pack and switch the that locale, edited a C/C++ and did Go to Definition on a #include header but it correctly opened the file in a new document.
I believe this is a VS Code bug (https://github.com/Microsoft/vscode/issues), because our extension doesn't control the UI or how documents are opened. Can you see if this bug repros without our C/C++ extension via doing a Go to Definition with some other language like TypeScript or use some other extension that provides Go to Definition?
You can close close the #include header or reference file, and ctrl+click the current file.maybe reproduce the bug. Go to Definition with Python("locale":"zh-cn") is normal.But C/C++ extension is not.
I still think this is a VS Code bug because we just send back to them a list of definition results and never do anything that could cause the contents to change, except if a format document is received. I've filed bug https://github.com/Microsoft/vscode/issues/66004 .
If you wanted to debug the issue yourself further, you could download our release extension at https://github.com/Microsoft/vscode-cpptools/tree/release , do Launch Extension, open the C/C++ Debug Protocol Output pane, clear it, do the repro, and check the output to see if there's anything unusual (you should see textDocument/definition, hover, textEditorSelectionChange, reportNavigation, codeAction messages).
Also, do you know if the document is actually being modified, i.e. if you save the file, do the changes get saved? Or is the in memory document just being rendered incorrectly?
Also, do you have any files.autoSave setting set, such as onFocusChange, with the editor.formatOnSave enabled? And do you have a multi-root workspace? It's theoretically, possible that you're hitting a case where the Go to Definition triggers a focus change, causing the formatOnSave to get invoked, and then somehow the formatting results for the target file are getting incorrectly applied to the source file, but I'm still not able to repro the issue (it could be some race condition?).
Also, it might be worth trying our 0.21.0-insiders3 release, since we fixed a lot of other stuff (https://github.com/Microsoft/vscode-cpptools/releases or C_Cpp.updateChannel set to "Insiders").
@RonnieLyu some more questions:
It have only the C++ extension enabled. It happens to the reference file(eg:function def/header file). I 'm not confirm the problem does not occur for JavaScript/TypeScript. And I see the problem is random. I used the settings of language("locale":"en"), After a while this problem reproduced. if the referenced file isn't opened. Ctrl+Click will open the referenced file or change the current file by the context of the referenced file. but used F12(Go to def)is not happen
Oh.....When I press CTRL and move the cursor to a function symbol , It maybe happen.(Not click)
this is normal
@RonnieLyu when this happens next time can please do a diff (I assume the project is under source control) so that we can see what has actually changed in the file. When doing the diff, please enable the show trim white space option
Type: General Input information below
Please review existing issues and our documentation at https://github.com/Microsoft/vscode-cpptools/tree/master/Documentation prior to filing an issue.
Describe the bug
To Reproduce Please include code sample and
task.json
files. Steps to reproduce the behavior:Expected behavior A clear and concise description of what you expected to happen.
Screenshots If applicable, add screenshots to help explain your problem.
hold on CTRL:
Additional context Add any other context about the problem here including log messages from the Output window.