Closed braincomb closed 1 year ago
In my memory prettier / prettyhtml line rules can't work pretty with upper <template></template>
, but I'm not sure currently. Could you share your breaking case?
Hi @johnsoncodehk ,
Here're a few GIFs demonstrating the issue, copy pasting creates new lines around the line being pasted in.
Edit: after some experimenting with different versions, I can see that newText = '\n' + newText.trim() + '\n';
is also present in 1.0.4
, but I'm not getting any issues with extra newlines as above.
A possible fix is ignoring range
parameter altogether; using full document.getText()
instead.
return {
format(document, _, opts) {
...
const fullText = document.getText();
....
return [
{
range: {
start: document.positionAt(0),
end: document.positionAt(fullText.length),
},
newText: newText,
},
];
},
};
Thank you for looking into this @patarapolw . I installed version 1.1.5
and can confirm the issue has been resolved.
I can see this behavior in both
prettier
andprettyhtml
plugins:Is there a technical reason why this is done? When copying and pasting text in
.vue
files, this creates unnecessary newlines which is frankly quite annoying.Genuinely curious.
Thanks!