Skip to content

Conversation

@CrutchTheClutch
Copy link

Attempts to fix #859

@CrutchTheClutch CrutchTheClutch changed the title Update FileHeaderLogic.cs Fix Exception from Header when cleaning up all code Mar 9, 2022
@codecadwallader
Copy link
Owner

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.

@lflender
Copy link
Contributor

lflender commented Mar 22, 2022

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.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

Exception when cleaning up all code: InsertFileHeaderDocumentStart must be called on the UI thread

4 participants