-
Notifications
You must be signed in to change notification settings - Fork 11
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
Key Binding erases file contents #3
Comments
Well that's not supposed to happen. Could you provide any details? Such as the OS you're using, the keybinding, your settings, the context of the problem. Also, if you could turn on the If you could post the results here, then we might be able to figure this out together. Thanks for bringing this to my attention. |
I running Visual Code 1.4 on Windows 10 64, with these user settings:
And this keybinding:
No output to console, by the way! |
Exact same Problem here. In Addition when I activate the onSave Feature nothing happens. |
This issue gave me huge headache, but I finally managed to fix it. First, I tried checking whether this had anything to do with reading the file using NodeJS's So, then I immediately assumed this had something to do with character encoding. After having spent several hours on that, I came to the conclusion that it could not be character encoding. I had completely isolated the issue from that. So then I started fiddling around with reading files. Because I could positively confirm that the contents of the *.tmp files were properly written, the issue had to be with reading them. That's when I tried reading the file without using the The solution was to drop the And that was that! Sorry for the long wait. Also, this writing and reading from files currently assumes UTF-8. So that is not very reliable. Unfortunately, there is no way to check the character encoding of a file in Visual Studio Code programmatically, yet. I added a feature request to the Visual Studio Code GitHub just for that. In the near future, I will have to implement a workaround for character encoding detection using a third-party package. For now, it will all be UTF-8. |
This resolves #3, where fixing a file would erase the contents. It was the result of the fs.readFileSync method which handled the file descriptor cursor position poorly. Using a read stream, we can set the file cursor position to the first line when reading from the temp file. Be aware, however, that this code assumes utf-8 character encoding throughout, which could cause a lot of issues. Hence we are waiting for a feature to be implemented with which extensions can get the a file's character encoding. Feature request here: microsoft/vscode#11690. Also added some more debug logging, as well as a convenience method that wraps a string in double quotes.
I have installed the extension and it happens that when I use the KeyBinding, it erases all the file contents.
The text was updated successfully, but these errors were encountered: