win7killer / vue-format

VSCode extension, format single file with '.vue'.(VSCode 插件,格式化单文件“.vue”代码)
https://marketplace.visualstudio.com/items?itemName=febean.vue-format
MIT License
47 stars 10 forks source link

当一行有多个标签时,格式后格式错乱 #12

Open lhajh opened 5 years ago

lhajh commented 5 years ago

Describe the bug [描述]:

格式前:

<p class="a" title="ggg"><span class="d" title="fdf"><span class="gg" title="gbfd">fdf</span></span></p>

格式后:

<p
  class="a"
  title="ggg"><span
class="d"
title="fdf"><span
class="gg"
title="gbfd">fdf</span></span></p>
win7killer commented 5 years ago

@lhajh 捋了捋,发现这种情况有点难受~需要有较大改动 暂时先关闭 attr_end_with_gt 配置使用;或者暂时关闭html格式化

win7killer commented 5 years ago

@lhajh 在 0.1.5 中使用优化方案来处理 issues#12 取消对 js-beautify 中 html.unformatted 标签的 属性断行【例如,span 标签,不在对其attrs 做断行处理,inline标签不作任何处理。如需格式化对应标签,可在 vue-format.js-beautify.html.force_format 中添加对应标签名,如“template”】

lhajh commented 5 years ago

@win7killer 喵?喵?喵?意思就是说现在只格式块元素?如果需要格式化 inline 标签,需要添加到 vue-format.js-beautify.html.force_format 中?我把 span 添加进去以后,还是出现上面的问题

那就是说这个问题暂时解决不了,先规避掉吗?

win7killer commented 5 years ago

@lhajh 按照 js-beautify 对 html 格式化的策略来说,对于 unformatted 的标签时不做任何处理的。 我这边用的方案暂时是解决不了,所以受影响的就是 unformatted 的标签,不会对 attrs 断行处理。

回头找到合适方案的话,会同步的~

lhajh commented 5 years ago

@win7killer 👌