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

Formatter messes up indentation (even its own) #234401

Open
Stokestack opened this issue Nov 22, 2024 · 1 comment
Open

Formatter messes up indentation (even its own) #234401

Stokestack opened this issue Nov 22, 2024 · 1 comment
Assignees
Labels
bug Issue identified by VS Code Team member as probable bug editor-autoindent Editor auto indentation issues javascript JavaScript support issues typescript Typescript support issues

Comments

@Stokestack
Copy link

Stokestack commented Nov 22, 2024

Does this issue occur when all extensions are disabled?: Yes/No
yes

  • VS Code Version: 1.95.3
    Commit: f1a4fb1
    Date: 2024-11-13T14:50:04.152Z
    Electron: 32.2.1
    ElectronBuildId: 10427718
    Chromium: 128.0.6613.186
    Node.js: 20.18.0
    V8: 12.8.374.38-electron.0
    OS: Darwin arm64 24.1.0

Steps to Reproduce:

  1. Open the attached TypeScript file in VS Code. Or not, since this site inexplicably won't let me attach the source file. So put the code below in a .ts file and open it in VS Code.
  2. Set the default formatter to the built-in JavaScript/TypeScript one.
  3. In the formatting settings, have "format on paste" off.
  4. Select a full if statement and right-click, then say "format selection." Note that the resulting indentation is correct.
  5. Put the insertion point in front of the brace on the first line of the if statement and press Return. Note incorrect indentation.
  6. Undo that and highlight a whole if statement, and then cut it.
  7. Paste. Note incorrect indentation of the braces and body. If you turn "format on paste" on, this erroneous pasting behavior stops. But it shouldn't happen with "format on paste" off either, because you're cutting and pasting entire lines, all the way from the left margin. No reformatting is necessary.
    Screen grab attached.https://github.com/user-attachments/assets/b52f28cd-4163-4921-97c0-40e8a88ab7a3

I'm not using any third-party formatter. Also, the JavaScript/TypeScript formatting options are being ignored. Screen shot of those options attached too.Image

This page won't let me attach the source file (fix that), so I'll paste its contents here:

class CommManager
{
	public sendOTP(OTP: string, EMail: string, phoneNbr: string): void
	{
        	if (!OTP || (!EMail && !phoneNbr))
        	{
			console.error("Missing OTP or E-mail & phone number for user verification.");
			return;
        	}

        	// This doesn't preclude sending to both, if we want to someday.
    
        	if(EMail)
       		{
			console.log(`Sending OTP to ${EMail}.`);
		}

		if(phoneNbr)
		{
			console.log(`Sending OTP to ${phoneNbr}.`);
		}
	}
}

export const commMgr = new CommManager();

@Stokestack
Copy link
Author

settings.json

Settings attached.

@jrieken jrieken assigned mjbvz and unassigned jrieken Nov 22, 2024
@mjbvz mjbvz added typescript Typescript support issues javascript JavaScript support issues editor-autoindent Editor auto indentation issues bug Issue identified by VS Code Team member as probable bug labels Nov 25, 2024
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
bug Issue identified by VS Code Team member as probable bug editor-autoindent Editor auto indentation issues javascript JavaScript support issues typescript Typescript support issues
Projects
None yet
Development

No branches or pull requests

3 participants