Omnisharp 1.25.7 and VScode formatting error .razor files

310 Views Asked by At

On my mac m1, when I try to auto format .razor files, Omnisharp throws the following error:

[Error - 16:20:32] Request textDocument/formatting failed. Message: Specified argument was out of the range of valid values. (Parameter 'Range end line 25 matches or exceeds SourceText boundary 25.') Code: -32000 [object Object]

With .cs files everything works as expected. I have already tried to reinstall VScode. Downgrading Omnisharp to 1.25.2 works, but then the formatting is broken ( Html indentation is not correct ). Does anyone have a solution for this? Thanks in advance! This drives me crazy...

    @foreach (var prodGroup in groupedProductsByCategory)
    {
      <div class="row mt-3">
  <h4>
    @prodGroup.FirstOrDefault(pg => pg.CategoryId ==
    prodGroup.Key)?.CategoryName
  </h4>
  <DisplayProducts Products="@prodGroup"></DisplayProducts>
</div>
      <hr class="mb-3" />
    }

What I have tried:

  • Downgrading Omnisharp
  • Reinstalling VSCode
  • Reinstalling all extensions
  • Changing lots of settings
0

There are 0 best solutions below