codecadwallader / codemaid

CodeMaid is an open source Visual Studio extension to cleanup and simplify our C#, C++, F#, VB, PHP, PowerShell, JSON, XAML, XML, ASP, HTML, CSS, LESS, SCSS, JavaScript and TypeScript coding.
http://www.codemaid.net
GNU Lesser General Public License v3.0
1.89k stars 356 forks source link

Checking "automatically run cleanup on file save" causes CSHTML file to not save. #922

Open falcon397 opened 2 years ago

falcon397 commented 2 years ago

Environment

Description

I checked the box in the options to "automatically run cleanup on file save". Then I go into my CSHTML file, make some formatting changes, and save the file. The formatting changes happen, but the file remains unsaved. Or perhaps the save is causing a change to occur after the format completes and saves. This seems to be unique to CSHTML files, going to my CS files the save/cleanup works as expected.

Steps to recreate

  1. Create CSHTML file.
  2. Create some poorly formatted HTML markup.
  3. Enable "automatically run cleanup on file save" in the CodeMaid options.
  4. Save CSHTML file.

Current behavior

The file saves, but I think it is modified after the save in some way, and the IDE puts an in the VS tab indicating the file has content to save. The images below are the before and after of saving the file with no additional edits on my part. I put a poorly formatted label tag in the file, CodeMaid fixed it correctly, but it leaves unsaved modifications after the save happens. The tab in the resulting image shows the file is modified. The flashed, so it appears that CodeMaid saved the file, and time stamp on the file suggests this is the case. I'm thinking CodeMaid must be altering the file after the save happens.

image

image

Expected behavior

The file should format itself, and save, and not have any further edits to the file.

codecadwallader commented 2 years ago

Thanks for reporting the issue. I have been able to reproduce it. I've looked at the CodeMaid diagnostics panel and confirmed the save event is only being triggered and executing once. I'm not sure what other behavior is kicking in after that event to cause it to modify further.

cklogs commented 1 year ago

@codecadwallader I have recently seen a related issue on plain .CS files. What I've seen is:

  1. have "automatically run cleanup on file save" enabled on the Code Main extension
  2. Modify an exisitng .CS file
  3. Save the file
  4. OUTCOME: file is saved correctly, but automatically set to an unsaved state in VS
brooksca commented 1 year ago

I'm seeing the exact same behavior as @codecadwallader

codecadwallader commented 1 year ago

I have not been able to reproduce the issue with C# files (using VS 17.4.0 Preview 2.1). Is it possible you have any other extensions installed that may also be triggered on save events?

codingdna2 commented 1 year ago

It's happening to me and to another collegue (plain CS). VS2022 + CodeMaid + XAML Styler and the default set of extensions (Live share, ML.NET, Xamarin, ..)

pchrist84 commented 1 year ago

I have the same problem VS 17.3.5. I disabled all extras except xaml styler. When I turn on code maid, files stop saving. Only on manual closing the file modal window appear with question. For me, this is a fatal error because it is impossible to work and debug normally.

image

kyleruddbiz commented 1 year ago

I have had the same experience as cklogs.

This same save behavior has affected .cs files and .xaml files for me.

rmdg82 commented 1 year ago

I have the same issue with cs files. Hope it will get fixed soon.

ernestfolch commented 1 year ago

Same issue with cs files. I'm using VS Enterprise 2022 (64-bit) Version 17.3.6 and CodeMaid Version 12.0.300

yborisovp commented 1 year ago

Same on every file in solution

AKruimink commented 1 year ago

Same issue here

Visual Studio 2022 v17.3.2 Project: Net Framework 4.8 Codemaid v12.0.300

Tried disabling every extension i have installed, only the moment codemaid is enabled does the issue occure. Happens in both .cs and .cshtml files (not tried other file types)

codecadwallader commented 1 year ago

Thanks all for chiming in.

I was previously able to reproduce the issue with .cshtml but not .cs or .xaml.

I am no longer able to reproduce the issue in .cshtml files (nor other file types) using the latest preview version of Visual Studio 2022 v17.4.0 Preview 6.0. Can anyone who is regularly seeing the issue try the latest version of Visual Studio to see if it resolves it for them as well?

ernestfolch commented 1 year ago

Thanks all for chiming in.

I was previously able to reproduce the issue with .cshtml but not .cs or .xaml.

I am no longer able to reproduce the issue in .cshtml files (nor other file types) using the latest preview version of Visual Studio 2022 v17.4.0 Preview 6.0. Can anyone who is regularly seeing the issue try the latest version of Visual Studio to see if it resolves it for them as well?

Today I've updated my Visual Studio to the lastest version v17.4.0 and I'm not having the issue with the .cs files, now I'm able to use the Automatic Cleaup On Save without issues.

kyleruddbiz commented 1 year ago

After using this for a while it does seem to be fixed for me as well. Thanks for the help!

yborisovp commented 1 year ago

As @ernestfolch says, I couldn't reproduce it too after update