codemaid icon indicating copy to clipboard operation
codemaid copied to clipboard

Fix Exception from Header when cleaning up all code

Open CrutchTheClutch opened this issue 2 years ago • 2 comments

Attempts to fix #859

CrutchTheClutch avatar Mar 09 '22 18:03 CrutchTheClutch

Thanks for opening the PR, I appreciate it. The code changes look pretty straight forward and good to me. May I ask what kind of testing you did with these changes?

I'm not sure why the build failed, it just seems to have exited. Perhaps it was just an intermittent issue although we haven't usually seen those.

codecadwallader avatar Mar 11 '22 13:03 codecadwallader

The build fails because it does not compile. Calling UIThread.Run on GetCurrentHeader does not return the expected return value.

There is an easier way to fix that issue, we only need to call UIThread.Run inside UpdateFileHeader, like this:


            switch ((HeaderUpdateMode)Settings.Default.Cleaning_UpdateFileHeader_HeaderUpdateMode)
            {
                case HeaderUpdateMode.Insert:
                    UIThread.Run(() =>
                    {
                        InsertFileHeader(textDocument, settingsFileHeader);
                    });
                    break;

                case HeaderUpdateMode.Replace:
                    UIThread.Run(() =>
                    {
                        ReplaceFileHeader(textDocument, settingsFileHeader);
                    });
                    break;

No further change is needed.

I encountered the issue (not sure why it didn't show up during my dev, I tested it dozens and dozens of times) and this change fixed it.

lflender avatar Mar 22 '22 17:03 lflender