Skip to content
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

<template> multi-line comments shift with each format #2505

Closed
jl8n opened this issue Mar 10, 2023 · 6 comments
Closed

<template> multi-line comments shift with each format #2505

jl8n opened this issue Mar 10, 2023 · 6 comments
Labels
bug Something isn't working

Comments

@jl8n
Copy link

jl8n commented Mar 10, 2023

Using Vue Language Features (Volar) v1.2.0 in VSCode

Before formatting:

          <!--
            <div>
              <p>Hello world!</p>
            </div>
          -->

First format:

          <!--
              <div>
                <p>Hello world!</p>
              </div>
            -->

Second format:

          <!--
                <div>
                  <p>Hello world!</p>
                </div>
              -->

Third format:

          <!--
                  <div>
                    <p>Hello world!</p>
                  </div>
                -->

and so on,

This does not happen with single line comments such as:

<!-- <div><p>Hello world!</p></div> -->
@pierresaid
Copy link

Same as #2470 and as #2478

@johnsoncodehk
Copy link
Member

This issue should have been fixed in 1.1.4 by #2420. Unfortunately I can't reproduce it at the moment.

@mrinc
Copy link

mrinc commented Apr 4, 2023

@johnsoncodehk - here is a file that it is doing it - https://gist.github.com/mrinc/84e27a1bc0fcdfa79be228c96c387286

You can actually see the formatting.
Vue.volar- v1.3.12
Vue.vscode-typescript-vue-plugin - v1.3.12

Maybe you can replicate the issue on your end with a copy of a file that is causing it.

Originally I thought it may be caused by errors in the file, but that doesn't seem to affect it, so it's definately something else.
From it's behavour, I believe there might be something to do with the position of the code.
Like every time we format, it adds 2 spaces as if you'd inner indent the code.
- which makes sense if you were to think of a div, inner code is indented.
So it might not be checking or validating the indent incorrectly - so something like that.

@mariusa
Copy link

mariusa commented Apr 7, 2023

Still happens with v1.2.0

Like every time we format, it adds 2 spaces as if you'd inner indent the code.

Right. Only for multi-line comments in <template> section in .vue files (if relevant, <script setup lang="ts">)

Here's how it looks, initial and then after a few Ctrl+S (with auto-format on Save)

Screenshot from 2023-04-07 14-06-18
Screenshot from 2023-04-07 14-06-29
Screenshot from 2023-04-07 14-06-39

editor.codeActionsOnSave is empty, but I've set vscode to auto-format on save.

@johnsoncodehk johnsoncodehk added bug Something isn't working and removed need info labels Apr 17, 2023
@johnsoncodehk
Copy link
Member

I can reproduce with the gist, thanks.

@mariusa
Copy link

mariusa commented Apr 17, 2023

Thank you for the fix! It works

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Something isn't working
Projects
None yet
Development

No branches or pull requests

5 participants