vscode-twig-language-2 icon indicating copy to clipboard operation
vscode-twig-language-2 copied to clipboard

Format on paste doesn't adhere to current tab depth

Open chasegiunta opened this issue 6 years ago • 15 comments

If pasting code in and the editor is formatting on paste, the code will always be reset to no tab depth. Even the simplest pasting of one random character will reset the whole line's tab depth to 0 characters/tabs.

chasegiunta avatar Jun 19 '18 18:06 chasegiunta

I can confirm this issue.

Roxas92 avatar Aug 02 '18 06:08 Roxas92

I am experiencing the same.

screen recording 2018-08-12 at 00 17

jeremysanchez avatar Aug 12 '18 06:08 jeremysanchez

Any solution yet? Having the same issue

goemaeret avatar Oct 02 '18 13:10 goemaeret

As much as it killed me to do so, I removed the extension. I have a feeling @mblode may have moved onto some bigger fish, but this project is a great start for a fork.

chasegiunta avatar Oct 02 '18 14:10 chasegiunta

Same here. Anyone find a fix or workaround for this?

ericrowan avatar Oct 23 '18 20:10 ericrowan

Hey guys, I have just pushed an update to Twig Language 2 with a brand new formatter using Prettydiff 3 which brings about some major bug fixes along with fixing this indentation issue. Please let me know if you are still having issues. Sorry about the lack of communication and slow development speeds but hopefully these updates have fixed some of your problems.

mblode avatar Dec 30 '18 16:12 mblode

@mblode ~Looks like initial "paste point" is correct now, but the formatter will do a line break unnecessarily (which is another issue by itself) which seems to ignore the tab depth.~

EDIT: I can't confidently say anything changed with this last update as I just realized Prettier was running on paste and interfering as well. I the "paste point" observation was based on a race condition between Prettier and this twig formatter. Disabling Prettier brings back the same behavior as before.

chasegiunta avatar Jan 02 '19 19:01 chasegiunta

Hmmm yeah, I had realised that on testing 2 days ago and haven't had a chance to look into it any further. But I'll do some research now and hopefully push a fix in the next couple of days. 👍

mblode avatar Jan 02 '19 21:01 mblode

@mblode Thanks for your continued work on this man!

ericrowan avatar Jan 04 '19 00:01 ericrowan

I'm having the same issues as described. When I paste, it will remove any indentation. Hitting "command + Z" will then re-indent the line to the appropriate place.

I've tried enabling/disabling Prettier and changing some of the settings but can't seem to narrow down the issue.

Thanks in advance for any thoughts or help!

Screen Recording 2019-05-23 at 10 26 AM

chrisobs13 avatar May 23 '19 14:05 chrisobs13

@mblode Is it be possible to override VSCode's Editor setting for "Format on Paste"? Unfortunately, disabling Format on Paste would disable that functionality globally.

chasegiunta avatar May 28 '19 17:05 chasegiunta

When I paste, not only does it reset the indentation, it adds a blank line below.

Any fix for this would be greatly appreciated :)

Flowgram avatar May 31 '19 13:05 Flowgram

Stale issue message

github-actions[bot] avatar Aug 25 '19 23:08 github-actions[bot]

same issue as @Flowgram

peterchang2 avatar Feb 18 '20 15:02 peterchang2

@peterchang2 this extension has been kind of abandoned. I've since moved to using Prettier and https://github.com/trivago/prettier-plugin-twig-melody

chasegiunta avatar Feb 18 '20 17:02 chasegiunta