plievone / vscode-template-literal-editor

Extension to VS Code. Use Ctrl+Enter to open ES6 template literals and other configured multi-line strings or heredocs in any language in a synced editor, with language support (HTML, CSS, SQL, shell, markdown etc).
https://marketplace.visualstudio.com/items?itemName=plievone.vscode-template-literal-editor
55 stars 5 forks source link

Formatting code inside synced editor #8

Closed vacekj closed 4 years ago

vacekj commented 6 years ago

Hi, first and foremost, let me thank you for this wonderful extension! It has significantly improved my experience with writing html directly in ES6 string literals.

Now on to the issue: Whenever I try to format HTML inside the synced editor via Alt+Shift+F, it formats the code, but it closes the window. Also, the first line of the string literal is automatically moved next to the backtick, which screws up formatting.

Any idea why this might be happening ?

plievone commented 6 years ago

Thanks, I'll look into it soon.

plievone commented 5 years ago

Hi @JouzaLoL ! Sorry for extra long delay. Do you have some specific beautifier or some other plugins that might affect formatting installed? Because for me the format document in synced HTML editor works ok (latest vscode 1.31-insider). If the window is closed immediately, it might mean that there has been some kind of syncing error (simultaneous edits to both editors?) and the editor is closed for safety (to avoid corrupting your templates with one-off char errors or similar). I would like to reproduce the situation if possible.

For the first line of string literal, we need to think about it. The editor itself just considers all content in template literal as content, so the first line feed is nothing special, and Code's formatter removes it. There might be a way to keep it by considering the content to start after the line feed, but at the same time one needs to consider that there are several kinds of non-html content that need to be able to remove any leading space if needed. Let me experiment a bit...