razor icon indicating copy to clipboard operation
razor copied to clipboard

Indent issue in Javascript function block

Open tsu1980 opened this issue 2 years ago • 7 comments

Describe the bug:

When I code format(Ctrl+K, Ctrl+D) a Razor file, Javascript function block indentation is broken.

Version used: VS2022 17.3.4 VisualStudio.17.Release/17.3.4+32901.215 Razor (ASP.NET Core) 17.0.0.2232702+e1d654e792aa2fe6646a6935bcca80ff0aff4387

To reproduce:

  1. Create a a.cshtml file in a project
<script>
  function sayhello() {
    console.log("hello");
  }
</script>
  1. Format code with Ctrl+K, Ctrl+D.

Expected behavior:

<script>
  function sayhello() {
    console.log("hello");
  }
</script>

Actual behavior:

<script>
  function sayhello() {
      console.log("hello");
  }
</script>

Indent size in a function block is 4.

Additional context: My indentation config is bellow. .editorconfig

[*.{css,scss,js,ts,vue,html,cshtml}]
charset = utf-8
indent_style = space
indent_size = 2

[*.cs]
charset = utf-8
indent_style = space
indent_size = 4

Tools > Options > Text editor > Javascript/Typescript > Tab Tab size: 2 Indent size: 2

tsu1980 avatar Sep 20 '22 01:09 tsu1980