-
Notifications
You must be signed in to change notification settings - Fork 1.5k
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
Document formatting causes sometimes messy and invalid code #10035
Comments
Ok, "great" news: the bug happened again while I disabled almost all my others extensions (only bug.mp4DEBUG logs
Extension settings{
"C_Cpp.intelliSenseEngine": "Default",
"C_Cpp.codeAnalysis.clangTidy.enabled": true,
"C_Cpp.codeAnalysis.runAutomatically": false,
"C_Cpp.clang_format_path": "/usr/bin/clang-format",
"C_Cpp.autoAddFileAssociations": false,
"C_Cpp.loggingLevel": "Debug"
} If I manually run I observed that the bug "degenerates" if lines are modified around. It starts around 0:40 of the following video, when I delete chars, then press bug2.mp4Please let me know what I can do more to help investigate this issue. 👍 |
If you set C_Cpp.loggingLevel to "Debug" and check the C/C++ logging pane for formatting logging can you locate at which point the garbage text is occurring? My guess is that the garbage text will appear in the input of formatting (because our internal document object got corrupted somehow). |
Also, are you opening your workspace folder via a symlink? If so, you're hitting bug #5061 . |
@sean-mcmanus I attached the "Debug" logs in my second message, does it contain what you're looking for (I don't know exactly what is the "garbage text")? The workspace is not opened with a symlink. It's a local folder which is then opened inside a devcontainer. |
Oh, the logging gets cut off after 1024 characters (we've increased that limit in our next release). Are you able to get a repro with < 1024 characters? |
Hey @sean-mcmanus, the bug happened today on another file. I removed code above and below the garbage text to limit the file size. It seems your guess was right, the garbage text appears in the input for some unknown reason. File: #include "segNet.h"
bool SegNet::updateInferenceSettings(
const weedcore::weedcom::InferenceSettings& inference)
{
m_modelPath =
std::visit([](auto&& arg) -> std::string { // All model types share the a "modelPath" argument.
return arg.modelPath(); }, m_model);
return true;
}
Logs:
Proof: bugg.mp4 |
I have encountered the same bug and it first happened weeks ago. The lint also shows some weired message, but everything works fine when I reload the window. |
Same problem |
It appears that something is causing our internal document object (input to formatting) to be into an invalid state. Is everyone who is reproing this on Linux? Does downgrading to 1.11.5 "fix" the issue? It would help to narrow down the potential changes that could have regressed this. Has anyone reproed this with 1.13.3? My guess is that it still would since we're not aware of fixing it. |
I've been seeing the same problem on Windows with the same observations and experiences noted here already. It is hard to force reproduction, but it seems there is already a good repro case here. I'll try to pay attention if it happens again and try things in order to help with the other questions. |
Hey @sean-mcmanus. I've been using |
This is happening to me again recently too, restarting vscode always fixes the issue. I'm using Linux. |
@Delgan It seems like some regression from a change in 1.12.0 to 1.12.3, but I looked through the changes and didn't see anything in particular that could cause it. By the time the format happens, the document is corrupted already, so it must be some previous operations that are corrupting the internal document. Does anyone know any good repro steps for corrupting the internal document? I can't seem to get a repro via edits. |
I spent over half an hour the other day doing edit/undo/redo in a file without observing any problem. It's difficult to know how to reproduce the error, it seems to happen randomly in the middle of a coding session. @sean-mcmanus What makes you think the regression was introduced between 1.12.0 and 1.12.3 and not between 1.11.5 -> 1.12.0 or 1.12.3 -> 1.12.4? Do you want me to try a different version to possibly help "bisecting" the regression? Or does it exist some debugging |
@Delgan My guess from reviewing the changes is that the bug doesn't repro in 1.12.0 because that only has some bug fixes that we don't believe have the potential to cause this regression -- if someone were able to get a repro with that version, it would certainly reduce the possibilities further. 1.12.1 added doxygen comment generation and code analysis fix formatting -- both of which theoretically could cause the bug, even though I don't see exactly how. We don't currently have a debug version that could get more info -- we're thinking about that possibility. |
Hi @sean-mcmanus, I have some news. I've been using Thus, I would say the regression was introduced between |
This should be fixed with 1.13.6: https://github.com/microsoft/vscode-cpptools/releases/tag/v1.13.6 . The bug should have started reproing with 1.12.0. |
This was the sort of problem that required a few hours of "normal" usage before the symptoms started to show. Today, I've been running with v1.13.6 all day and have seen no problems so far. Great job! And thank you! |
Environment
Bug Summary and Steps to Reproduce
Bug Summary:
From time to time, when saving and thus formatting a C++ file, the file ends up in an invalid "state". Code blocks are mixed together for an unknown reason. Different lines are intertwined with each others. I don't know how to reproduce this mistake systematically. It happens relatively rarely (once a week or so).
Screencast.from.05-10-2022.17_04_58.webm
Steps to reproduce:
ctrl+S
)ctrl+Z
)Debugger Configurations
Debugger Logs
Other Extensions
Possibly related extensions:
Additional Information
This problem happened to myself and a colleague of mine on two different computers, so it's not unique to my setup. However, we're sharing the same codebase and the same devcontainer, so it might be related to something in our dev environment.
If I remember correctly, calling the "Format document" command without saving also generates the error. The bug appeared about 2 months ago I would say.
It's not related to the content of the file. If I close VS Code and re-open it, then it works.
It is not easy to reproduce so unfortunately I do not have any additional information to provide. I'll try to update the ticket with logs when it reproduces.
The text was updated successfully, but these errors were encountered: