microsoft / TypeScript

TypeScript is a superset of JavaScript that compiles to clean JavaScript output.
https://www.typescriptlang.org
Apache License 2.0
100.8k stars 12.46k forks source link

End tags ignore indentation rules in Javascript React #39777

Open mattrossman opened 4 years ago

mattrossman commented 4 years ago

TS Template added by @mjbvz

TypeScript Version: 4.0.0-dev.20200727

Search Terms


Steps to Reproduce:

  1. Create a file of type "Javascript React" (e.g. by creating a .jsx file)
  2. Write some markup with incorrect indentation:
    <div>
hello
        </div>
  1. Run "Format Document" (or Shift+Alt+F)

Everything will be auto-indented except the closing </div> tag:

<div>
    hello
        </div>

This happens with any type of element including custom React components. It seems to only occur when an element contains plain text.

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

mattrossman commented 4 years ago

@mjbvz Why was this transferred to the Typescript repo? I am not not using Typescript.

RyanCavanaugh commented 4 years ago

@mattrossman the formatter lives in this repo

bhushan-shah-dev commented 4 years ago

Hello! I am new to open-source and this seems like a good first issue to work on.

I was able to reproduce the issue using the local built/local/tsc.js. I read up on the formatter README, and tried to debug the issue. I set up the language server debugger using the instructions here, but I am unable to debug. The debugger does not break on a debugger statement inside formatSpan. Am I missing something?

Also, any pointers regarding the actual fix would be appreciated, as I try to debug the issue.