aspnet / Tooling

Issue tracker and info on Visual Studio tooling for ASP.NET
Other
256 stars 124 forks source link

Format on paste setting does not work in .cshtml (Razor - VS 2015) #914

Closed Inspyro closed 6 years ago

Inspyro commented 7 years ago

When disabling format on paste for C# + HTML in the Visual Studio settings, usually code does not get formatted on paste (as expected)

In razor files, when you copy and past something like this statement:

@Html.AttributeEncode("test")

it also works as intended.

However when you mark the "." (dot) and do something like cut (Ctlr+X) and paste (Ctlr+V) (or just paste), the html helper call gets formatted (in our case like this):

@Html.AttributeEncode ("test")

This is unexpected and even leads to a compile failure (razor @ syntax does not support whitespaces)

fschmied commented 7 years ago

Note: The call gets formatted like that only if the C# Formatting settings are configured to include a space before the opening parentheses. The bug is therefore not the space per se, it is that the space is inserted while pasting even though format on paste is off (for both C# and HTML Text Editor settings).

mlorbetske commented 7 years ago

@ToddGrun can you take a look?

mlorbetske commented 7 years ago

TFS Bug#362027

jodavis commented 6 years ago

Razor formatting has been improved in the most recent version of Visual Studio. We can no longer reproduce this issue.