Fixes issue with saving files and makes empty files and New TLdraw command work (#258)

* Fixes issue with saving files and makes empty files and New TLdraw command work

* v0.1.16

* v0.1.18

Co-authored-by: Steve Ruiz <steveruizok@gmail.com>
This commit is contained in:
Francois Laberge 2021-11-10 14:42:28 -05:00 committed by GitHub
parent a95b581e07
commit 913b4dc5d2
No known key found for this signature in database
GPG key ID: 4AEE18F83AFDEB23
2 changed files with 6 additions and 3 deletions

View file

@ -2,7 +2,7 @@
"name": "tldraw-vscode",
"displayName": "TLDraw",
"description": "The TLDraw Extension for VS Code.",
"version": "0.1.15",
"version": "0.1.18",
"license": "MIT",
"publisher": "tldraw-org",
"repository": {

View file

@ -160,10 +160,13 @@ export class TLDrawEditorProvider implements vscode.CustomTextEditorProvider {
case UI_EVENT.TLDRAW_UPDATED: {
// Synchronize the TextDocument with the tldraw components document state
const prevFile = JSON.parse(document.getText()) as TLDrawFile
const nextFile = JSON.parse(e.text) as TLDrawFile
nextFile.document = sanitizeDocument(prevFile.document, nextFile.document)
// There's no reason to sanitize if the file contents are still an empty file.
if( document.getText() !== "" ){
const prevFile = JSON.parse(document.getText()) as TLDrawFile
nextFile.document = sanitizeDocument(prevFile.document, nextFile.document)
}
this.synchronizeTextDocument(document, nextFile)
break