You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
{{ message }}
Repository navigation
The indentation is incorrectly changed after pasting #147223
Does this issue occur when all extensions are disabled?: Yes
VS Code Version: 1.66.0
OS Version: Windows 7
Steps to Reproduce:
The indentation of the existing closing code is changed after pasting, depending on the level of indentation of the copied code. Here is the animated screenshot:
the first copied block (top) has indentation with one tab more than the resulting indentation -> after pasting, the existing closing bracket has one tab less indentation;
the second copied block (bottom) has indentation with three tabs less then the resulting indentation -> after pasting, the existing closing bracket has three tabs more indentation.
I have "editor.autoIndent": "full" because I like that option of VSCode very much with its automatic indentation based on the surrounding code.
Maybe these issues are related: #86301 and #85781.
It looks like that the indentation rules for JS is not covering this case. Currently the indentation rules for
auto indent feature in VS Code is regex based, which doesn't really understand the scope (function, statement) etc. Formatting works more consistently in this scenario, so I would recommend to enable formatting on type or save. Closing this as we don't expect to get around it in the near future.
This is not problem only with JS files. Here is HTML:
Here is CSS:
And JSON:
I don't understand how your regex code could add the proper number of tabs/space characters just fine to all pasted lines, except the last one.
Could you please point me in the right direction, where should I look in your code? I am not that good with TypeScript, but I am quite fine with regular expressions and maybe I could fix that for you.
Activity
rebornix commentedon Dec 13, 2022
It looks like that the indentation rules for JS is not covering this case. Currently the indentation rules for
auto indent feature in VS Code is regex based, which doesn't really understand the scope (function, statement) etc. Formatting works more consistently in this scenario, so I would recommend to enable formatting on type or save. Closing this as we don't expect to get around it in the near future.
Z-E-D commentedon Dec 13, 2022
This is not problem only with JS files. Here is HTML:

Here is CSS:

And JSON:

I don't understand how your regex code could add the proper number of tabs/space characters just fine to all pasted lines, except the last one.
Could you please point me in the right direction, where should I look in your code? I am not that good with TypeScript, but I am quite fine with regular expressions and maybe I could fix that for you.
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline
Fix indentation issues when pasting with trailing newline