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

Formatting on paste changed existed code format but not the new one #72036

Closed
nyaachen opened this issue Apr 10, 2019 · 1 comment
Closed

Formatting on paste changed existed code format but not the new one #72036

nyaachen opened this issue Apr 10, 2019 · 1 comment
Assignees
Labels
editor-autoindent Editor auto indentation issues under-discussion Issue is under discussion for relevance, priority, approach

Comments

@nyaachen
Copy link

  • default settings
  • install C/C++ intellisense
  • write down some complete code
  • paste an incomplete code with a leading newline
    (for example you paste \nint and without the ending ;, this often occurs when you meant to paste a common used long declare part and then write down the variable name, and somehow you decided to include the leading newline, often can be done by using the touchscreen to position and then pressing Shift+up so you selected the whole line before your cursor, and also the leading newline)

result:
the already existed code after your pasted code is incorrectly auto-indented

This will cause more confusing especially when you paste code with an unpaired bracelet, for example {, which will cause the whole indent after the code changed until the next bracelet.

This should consider a bug for the reason that once you paste uncompleted code(which can be detected easily using the intellisense), in most time you meant to modify the new codes but the existing completed ones. Unfortunately there's no way to avoid these unless you choose to disable the format-on-paste, which will lead to no indent adjusting on paste at all.

@vscodebot vscodebot bot added the editor-autoindent Editor auto indentation issues label Apr 10, 2019
@rebornix rebornix added the bug Issue identified by VS Code Team member as probable bug label Oct 22, 2019
@rebornix
Copy link
Member

rebornix commented Nov 3, 2020

This is due to the limited architecture (regex based indentation rules and only support limited code styles), we may want to consider using formatters if they exist for indenation adjustment (if interested, we can discuss in #19847).

For this particular issue, if the indentation rules are leading to more trouble than having no auto indent, you can set editor.autoIndent to advanced to disable the regex based indentation adjustment or use auto formatting (editor.formatOnType, editor.formatOnPaste). As we don't have an easy good-enough fix for it, we close it for now and explore better solutions through issues like (#19847, #34621 or #66235).

@rebornix rebornix closed this as completed Nov 3, 2020
@rebornix rebornix added under-discussion Issue is under discussion for relevance, priority, approach and removed bug Issue identified by VS Code Team member as probable bug labels Nov 3, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Dec 18, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
editor-autoindent Editor auto indentation issues under-discussion Issue is under discussion for relevance, priority, approach
Projects
None yet
Development

No branches or pull requests

2 participants