News for hackers. Stuff that matters.
Re:Visual Studio Code is randomly erasing included header fi... by Jedd on Saturday March 19, 2022 @08:19PM (#30738787)
One of the comments on that issue:

> Due this bug the content of one of my source file which had 3000 line, was deleted .

> I don't use version control system.

> How can i restore it?

I know we're in a cosy bubble on HN, but in 2022 do we really still have developers (having one 3k loc file is non-trivial enough to warrant that appellation) who don't do any kind of backups, via VCS or otherwise?

Re:Visual Studio Code is randomly erasing included header fi... by adhesive_wombat on Sunday March 20, 2022 @04:14AM (#30741011)
One of the questions in my interview gave me an insight into this:

Them: how many people have to work on a project before version control should be used?

Me: Uh, one? Git init is the first thing you do after naming the directory.

Them: audible relief

One wonders what they have seen.

Re:Visual Studio Code is randomly erasing included header fi... by bravetraveler on Sunday March 20, 2022 @10:59AM (#30743158)
I like it, but without a remote it's a little like taking backups on another partition of the same disk
Re:Visual Studio Code is randomly erasing included header fi... by adhesive_wombat on Sunday March 20, 2022 @01:29PM (#30744609)
Well even with just one person committing, you'd still have a remote. Even for personal stuff that you don't want to publish, you can still use BitBucket private repos (or bare repos on any server you have access to).

To be honest, backups wasn't what was first in my mind when answering that question (backups are a separate system in my mind), it was that being able to "git diff" to the last time it was working is often all you need to do to get your head round why it's not working now.

Re:Visual Studio Code is randomly erasing included header fi... by tinus_hn on Sunday March 20, 2022 @06:17PM (#30747270)
So not backups but better than nothing. It would have solved the stated problem of ‘a source file accidentally got deleted’.
Re:Visual Studio Code is randomly erasing included header fi... by yakak on Sunday March 20, 2022 @11:39AM (#30743557)
IMO losing a project from an inexperienced developer that isn't yet integrated is a lesser problem than getting that project with no history and whole lot of random debugging experiments that went on long enough that they couldn't be reversed in an editor's undo.
Re:Visual Studio Code is randomly erasing included header fi... by LilBytes on Saturday March 19, 2022 @11:47PM (#30739896)
Tragically yes, my organisation has one.

Fortunately he uses local SVN in spite of the training we've provided him to use Azure DevOps.

You better believe he's not the exception. Worse yet he's not older and/or capable, or competent. He was hired as a shadow developer team of one to get and achieve certain outcomes that the developer team couldn't achieve in their desired timeframes.

I'm trying to move him to using modern tooling (if you were to call CI/CD and Git 'modern') but it's agonising. Fortunately I'm building a case to make his apps production so his services will fall under my responsibility of monitoring as the lead SRE. I'm documenting as I go and if he doesn't improve, I'll be responsible for documenting his demise.

Re:Visual Studio Code is randomly erasing included header fi... by kbelder on Tuesday March 22, 2022 @12:59PM (#30768588)
>He was hired as a shadow developer team of one to get and achieve certain outcomes that the developer team couldn't achieve in their desired timeframes.

>I'm trying to move him to using modern tooling ... building a case to make his apps production so his services will fall under my responsibility

Hmm...

Re:Visual Studio Code is randomly erasing included header fi... by Osiris on Saturday March 19, 2022 @08:28PM (#30738827)
It's even weirder given that the bug was in a beta/pre-release version.

I wouldn't use a pre-release of VS Code on anything I didn't have a backup of.

Re:Visual Studio Code is randomly erasing included header fi... by duped on Saturday March 19, 2022 @11:19PM (#30739767)
Wasn't even pre-release of VS Code, but an extension
Re:Visual Studio Code is randomly erasing included header fi... by rurban on Sunday March 20, 2022 @05:37PM (#30746917)
I've looked into the commits, but found no fix in cpptools and neither in vscode core. it's not referenced in the 2 tickets neither.

did you find the commit fixing this? I've only looked for 10min.

Re:Visual Studio Code is randomly erasing included header fi... by tomjen3 on Sunday March 20, 2022 @06:24AM (#30741512)
I have some scripts that are not in version control and some applications where I have just run git init, but not pushed them to anything.

That said if I was teaching somebody to code, I would not encourage them to use git to begin with, since it is powerful but also hard to use.

I hope he is learning to code.

Re:Visual Studio Code is randomly erasing included header fi... by Shadonototra on Sunday March 20, 2022 @07:31AM (#30741782)
why would anyone need to backup a file to open it in "text editor"??

please enlighten me, file deletion/corruption is to be expected in a software made by a multi trillion dollar company?

this is the stupidest take i ever read

"guys, backup your files before you open it in your text editor, they can get corrupted if a troll is nearby"

Re:Visual Studio Code is randomly erasing included header fi... by nulld3v on Sunday March 20, 2022 @07:53AM (#30741902)
Shit happens. Have backups. Not a hot take...

There are a million ways your data can get corrupted. And it happens when you least expect it.

Re:Visual Studio Code is randomly erasing included header fi... by Shadonototra on Sunday March 20, 2022 @08:08AM (#30741981)
yeah, my bad, i shouldn't expect microsoft to be a good software company, you are right

the blame is on the users! freaking stoopid users

Re:Visual Studio Code is randomly erasing included header fi... by Jedd on Sunday March 20, 2022 @08:37PM (#30748550)
You seem to be excessively agitated by this thread.

As per another sibling comment, I also tried to find the actual extension file that was the cause of this problem -- and could not. It may well be a third party author, rather than direct from the infallible 'multi-trillion dollar company' (as if acquired wealth is any indication of quality). Having said that, I don't know why a) you're misinterpreting this as an attack on Microsoft Corp, and b) you're then being so personally affronted by it.

To your initial snarky question:

Everyone should have backups of all their important files, and this is never (solely) to protect them from the dangers of 'opening in a text editor', but to protect them from accidental corruption or loss from any cause.

For a c++ developer, with at least one source file > 3k loc, who'd gone out of their way to install a c++ extension, and then enabled a pre-release flag for that extension, I'm supremely surprised they weren't ahead of the curve on this.

Re:Visual Studio Code is randomly erasing included header fi... by Shadonototra on Monday March 21, 2022 @03:05AM (#30751082)
I am not agitated, i am baffled by the stupid recommendation of microsoft employees

I don't use vscode myself, i pity the ones who have to use it

--

> Everyone should have backups of all their important files, and this is never (solely) to protect them from the dangers of 'opening in a text editor', but to protect them from accidental corruption or loss from any cause.

Nobody said they opened an important file, stop trying to make it sound like the user is stoopid

What if you want to open a temp file you copy pasted from a blog post, you don't back up this, you can go back and copy/paste again, but the fact remains, the software is trash

> For a c++ developer, with at least one source file > 3k loc, who'd gone out of their way to install a c++ extension, and then enabled a pre-release flag for that extension, I'm supremely surprised they weren't ahead of the curve on this.

Yeah, again the user is the one to blame, not the stoopid software that is broken and needs pre-release flags to function correctly

They can nuke my computer too because it is a "pre-release flag" after all, what, you don't backup your whole computer? you stoopid user

Loosing time, being disrespected by software company who spit bloated trash at you and then blame you for trying to make said software a little bit better

Re:Visual Studio Code is randomly erasing included header fi... by Jedd on Monday March 21, 2022 @06:11AM (#30752262)
> Nobody said they opened an important file, stop trying to make it sound like the user is stoopid

Are you trying to say 'stupid'?

I'm not asserting the user is stupid, but I am expressing bewilderment that someone with the requisite technical skills to be in the position they're in (refer my post above) would _not_ have their code in source control, and/or (better yet) backed up on a different machine.

I'll also assert that anyone that states they wish to recover a file has, by definition, just assigned some importance to that file.

If you read that guy's (TavakoliAli) later comments you'll see they don't have enough time to rewrite that file. At 3k lines, that's no wonder, but further confirms my point.

Re:Visual Studio Code is randomly erasing included header fi... by nulld3v on Sunday March 20, 2022 @02:36PM (#30745303)
Nobody said that the blame is all on the users. Also, you can blame Microsoft all you want, it ain't going to get your data back.
Re:Visual Studio Code is randomly erasing included header fi... by Shadonototra on Monday March 21, 2022 @03:15AM (#30751154)
> Also, you can blame Microsoft all you want, it ain't going to get your data back.

What a wrong mindset

So Microsoft can spit all the bloated and buggy trash, they shouldn't be held responsible?

Who cares about the data loss, important or temporary, time was lot, not even respecting your users, you should be ashamed at microsoft

Where is your standard of quality? it's the size of an electron?

Re:Visual Studio Code is randomly erasing included header fi... by nulld3v on Monday March 21, 2022 @03:26AM (#30751232)
> What a wrong mindset

> So Microsoft can spit all the bloated and buggy trash, they shouldn't be held responsible?

> Who cares about the data loss, important or temporary, time was lot, not even respecting your users, you should be ashamed at microsoft

> Where is your standard of quality? it's the size of an electron?

Hmm, the problem is that you are talking to someone who already mostly agrees with you...

I never said that you shouldn't blame Microsoft. That is what I was talking about in my last comment: "Nobody said the blame is all on the users".

You should absolutely blame Microsoft. I actually refuse to even install VSCode because of the telemetry. But again, blaming Microsoft isn't going to get your data back.

It's like having a house but not putting a lock on it. Then some burglar comes in and trashes your house.

Like yeah, blame the burglar. The burglar should go to jail. But even if you put the burglar in jail, all the damage to your house doesn't just disappear.

So put a lock on your door and maybe add some cameras too. Then your house won't get trashed and the next time a burglar comes maybe you can even catch them and put them in jail with your security cameras. Best of both worlds.

Re:Visual Studio Code is randomly erasing included header fi... by lovingCranberry on Saturday March 19, 2022 @06:52PM (#30738291)
People use VSC for c++? I tried to use it once, but nothing really worked out of the box and the experience was so much worse than any other c++ IDE. Same with .Net in VSC.

Always felt like Microsoft wants to push me towards their "main" Visual Studio for c++ and .Net by keeping the VSC experience for these languages bad.

Re:Visual Studio Code is randomly erasing included header fi... by ncake on Saturday March 19, 2022 @07:37PM (#30738566)
I've had the opposite experience, and everything just works once you install the suggested extensions.

For C++ specifically you just need to create a .vscode/c_cpp_properties.json file to tell the intellisense where to find include folders, which defines to assume, and such.

Re:Visual Studio Code is randomly erasing included header fi... by CalChris on Saturday March 19, 2022 @07:05PM (#30738368)
I use VSC for C++. I use the clangd and VSCode NeoVim extensions. I don't use it as an IDE but as a code editor, it's the best I've had.

Visual Studio and Visual Studio Code have nothing but two words in common. Dunno why VSC is called that. But on OSX, I just type code on the command line.

Re:Visual Studio Code is randomly erasing included header fi... by seabrookmx on Saturday March 19, 2022 @07:08PM (#30738386)
I daily drive the C# extension in VSCode and it's great. The debug inspector is slower than I recall in "real" VS but I'm also using it on Linux via WSL, so it might be because of omnisharp.
Re:Visual Studio Code is randomly erasing included header fi... by chrismcb on Saturday March 19, 2022 @06:59PM (#30738337)
Visual studio code works just fine for c++. Out of the box. You may need to install the liner but that's it. I don't think it is as good as visual studio, but it isn't that bad that they are trying to push you to another ide.
Re:Visual Studio Code is randomly erasing included header fi... by adhesive_wombat on Sunday March 20, 2022 @04:19AM (#30741036)
VS Code is a competent enough almost-IDE at least for a CMake project.

The main issue I have so far is remote debugging in gdb appears not to work very well (you can step but you can't use normal gdb commands on the console like you can locally).

Also the autocompletion seems to work only sometimes but that's likely my fault since I haven't actually configured that.

So far, it's working better for me than Sublime did, which was very laggy at times. Both are memory hogs, though.

Re:Visual Studio Code is randomly erasing included header fi... by emerged on Sunday March 20, 2022 @08:17AM (#30742034)
RemoteSSH extension is a far easier approach to debugging C++ remotely in VScode.
Re:Visual Studio Code is randomly erasing included header fi... by adhesive_wombat on Sunday March 20, 2022 @01:45PM (#30744796)
Interesting! Can you then debug remotely but still use local symbols and sources? The remote is a pretty weedy embedded platform, so you don't want to compile there, and I don't think there is even enough disk space for a complete checkout of the source. So you want to just run gdbserver there and have all the rest of the debugging junk running on a "real" computer.
Re:Visual Studio Code is randomly erasing included header fi... by emerged on Monday March 21, 2022 @11:40AM (#30755324)
It behaves as if you’re local to the machine. Changed my life when I first found it.
Re:Visual Studio Code is randomly erasing included header fi... by IshKebab on Sunday March 20, 2022 @02:48PM (#30745398)
> almost-IDE

It is an IDE!

Re:Visual Studio Code is randomly erasing included header fi... by zen_1 on Sunday March 20, 2022 @10:27AM (#30742870)
For what it's worth, my partner and I have been using VSC for our C++ kernel/project in our course, and we've found it to work really well after some setup (mainly CMake and cross-compiler setup).

Sure, you don't get the same level of refactoring ability that you would from say, intellij + kotlin, but compiler warning/error integration and going to declaration/definition both work, which is enough for our purposes.

Re:Visual Studio Code is randomly erasing included header fi... by smackeyacky on Saturday March 19, 2022 @07:08PM (#30738396)
I prefer coding .NET in VSCode, although I really only use the debugger and the code completion. Visual Studio hides too much of the build process for me.

Never used it for C++ though.

Re:Visual Studio Code is randomly erasing included header fi... by chrismsimpson on Saturday March 19, 2022 @06:54PM (#30738308)
Latest .NET/C# and LLVM/Clang work a charm for me.
Re:Visual Studio Code is randomly erasing included header fi... by CornCobs on Saturday March 19, 2022 @09:55PM (#30739305)
I've been forced to use visual studio for c++ with cmake integration and I must say no matter how lacking VSC is, I don't think visual studio does much better.

Refactoring capabilities are woefully inadequate or just don't work, intellisense is often plain wrong, it doesn't detect when a rebuild or when cmake cache needs to be regenerated often enough, the list goes on and on

Re:Visual Studio Code is randomly erasing included header fi... by mdaniel on Saturday March 19, 2022 @11:08PM (#30739718)
If you don't like VS, you may enjoy CLion, as it uses CMake as its primary build system. I was flabbergasted at how poor the Refactor menu is in VS, and I now understand why Reshaper makes so much money

https://www.jetbrains.com/clion/

If you're an adventurous person, you can also use their EAP builds for free until the EAP cycle ends: https://www.jetbrains.com/clion/nextversion/

They always say "EAPs are pre-release and may have sharp edges" but TBH I've been choosing the EAPs because they often come with the most features. Only 1 out of every 20 releases has some kind of "wtf" experience

Re:Visual Studio Code is randomly erasing included header fi... by klysm on Sunday March 20, 2022 @02:03AM (#30740524)
I had the exact same thought about C# in VSC being intentionally bad this week. There’s so many conflicts of interest within Microsoft’s tech ecosystem.
Re:Visual Studio Code is randomly erasing included header fi... by mbrodersen on Sunday March 20, 2022 @08:57PM (#30748747)
Yep. It works great.
Re:Visual Studio Code is randomly erasing included header fi... by donkarma on Saturday March 19, 2022 @06:20PM (#30738071)
Apparently a bug in the CPP addon with uninitialised memory, doesn't repro with debug logging.

https://github.com/microsoft/vscode-cpptools/issues/9041

Re:Visual Studio Code is randomly erasing included header fi... by CJefferson on Saturday March 19, 2022 @07:51PM (#30738654)
Note the bug is now fixed, and was only ever in a pre-release, which you had to opt in to getting.

Still a serious bug of course!

Re:Visual Studio Code is randomly erasing included header fi... by mey on Sunday March 20, 2022 @01:12AM (#30740337)
Might need to clarify the title to be that this is the C/C++ extension.
Re:Visual Studio Code is randomly erasing included header fi... by klysm on Sunday March 20, 2022 @02:04AM (#30740528)
I would consider the C/C++ extension to be “part of” VSC as it’s a core extension owned by Microsoft. But still good it wasn’t just the editor magically nuking files!
Re:Visual Studio Code is randomly erasing included header fi... by zozbot234 on Sunday March 20, 2022 @10:18AM (#30742796)
Looks like this newfangled "political protest" thing is becoming a meme in FLOSS development. Now even VS Code is doing it.
Re:Visual Studio Code is randomly erasing included header fi... by userbinator on Saturday March 19, 2022 @07:08PM (#30738385)
I've never been too fond of IDEs and all the complexity they bring/encourage. When they work they can be helpful, but when things go wrong, they tend to go really wrong. Silent automatic updating is another one of those scary things that you don't notice until it's too late.

As Dijkstra says, "simplicity is a prerequisite for reliability."