codemaid
codemaid copied to clipboard
Fix Exception from Header when cleaning up all code
Attempts to fix #859
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.
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.