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

Pasting TS code removes indentation #167299

Closed
hediet opened this issue Nov 26, 2022 · 4 comments
Closed

Pasting TS code removes indentation #167299

hediet opened this issue Nov 26, 2022 · 4 comments
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug formatting Source formatter issues
Milestone

Comments

@hediet
Copy link
Member

hediet commented Nov 26, 2022

Copy this TS code:

export type IncludeReference =
	| BaseReference
	| SelfReference
	| RelativeReference
	| TopLevelReference
	| TopLevelRepositoryReference;

export const enum IncludeReferenceKind {
	Base,
	Self,
	RelativeReference,
	TopLevelReference,
	TopLevelRepositoryReference,
}

Create an new TS file, disable all auto formatters and paste the copied source.

Actual result:

export type IncludeReference =
| BaseReference
| SelfReference
| RelativeReference
| TopLevelReference
| TopLevelRepositoryReference;

export const enum IncludeReferenceKind {
Base,
Self,
RelativeReference,
TopLevelReference,
TopLevelRepositoryReference,
}

Expected result: Indentation should be preserved.

Maybe this was caused by a community PR that changed how enter rules are applied to pasted text.

@ssigwart
Copy link
Contributor

@hediet, I thought you might be referring to #136579, so I was trying to test this out in case my branch broke something. I'm having a little difficulty duplicating this. Maybe I have the wrong settings. I have typescript.format.enable and editor.formatOnPaste disabled.

However, I do notice something odd about copying from the code in your GitHub comment. If I manually copy and paste it, I don't see what you do. However, if I use the copy icon GitHub provides, the copied text includes an extra newline at the top.
If I paste that in the current VS Code version or Insider, I see what you're seeing, but also that line 1 is a blank line.

I think what might be happening is that GitHub is not properly displaying your code. I'm guessing the code you actually wrote includes a blank line above it, but GitHub won't render it.

Since I see this in version 1.73.1, I don't think it's my branch that causes this, but please let me know if you want me to try to track down the issue here.

@ssigwart
Copy link
Contributor

@hediet, I submitted #167687 that seems to fix this.

@hediet
Copy link
Member Author

hediet commented Nov 30, 2022

This happens when pasting the text on the second line:

Code_-_Insiders_RwT0sgdVhu

@hediet hediet added bug Issue identified by VS Code Team member as probable bug formatting Source formatter issues labels Dec 5, 2022
@mjbvz mjbvz added this to the Backlog milestone Dec 6, 2022
@aiday-mar
Copy link
Contributor

Issue closed with the PR #167687

@microsoft microsoft locked and limited conversation to collaborators Jun 11, 2024
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
bug Issue identified by VS Code Team member as probable bug formatting Source formatter issues
Projects
None yet
Development

No branches or pull requests

5 participants