Today, I fixed the two major outstanding bugs in WinUIpad, so it's time to wrap up this project ... for now.
I will definitely revisit this project in the future. There are some fit and finish changes I need to continue thinking about. And perhaps there will be a future focus month when I work on adding the AI-based writing features we see in Notepad. But for now, it's time to move on.
Bug fix: Closing one app window closes all app windows
This bug predates my use of Clairvoyance AI to get multiple tabs/documents working: If you had two or more instances of WinUIpad running and closed one of them, it would close all the app instances. I figured I'd be able to fix this, perhaps by maintaining a count of the app instances. But then I looked at the code and realized the fix would be even simpler.
Because there are multiple ways to close the app/window, there's a TryExitAsync() helper method that's called by all of them (like the ExitMenuClick() event handler that runs when the user clicks File > Exit). This method tries to close each tab in the current window and, if it succeeds, it calls SaveSession() to save the app session state and then SaveWindowSettings() to save the user settings. And then it called this:
Application.Current.Exit();
And that, clearly, was why all app instances would close: It wasn't closing the window, it was closing the app, including all app windows (and/or instances). The Windows App SDK is problematic, but I was positive it would have a Window.Close() method, and it does. And so I figured there must be some reason I wasn't using that.
But there wasn't. Instead, Window.Close() works as it should. If there are other app windows open, it just closes that window. If there are no other app windows open, it closes the app too. Could it really be this easy? I replaced the line of code noted above with the following to find out:
Close();
And sure enough, it works. I have no idea why this was like it was before, but I believe it's fixed.
Bug fix: A newly opened document is marked as having unsaved changes
This bug was introduced somewhere in the Clairvoyance AI-based updates: When you opened a document, it would appear in the editor, but then the "unsaved changes" indicator would appear next to the filename in the tab. Since you just opened a document, it hasn't been changed in any way, and so that indicator should not appear at that time.
This one was a lot less obvious.
The code in the OpenMenu_Click() event handler runs when the user opens a document. There's a lot of code in there because there are two ways in which a document could open—in the current tab or in a different tab—but both blocks of code correctly set the IsModified property of the document object instance to false. So the issue had to be somewhere else. And there were two candidates, since the UpdateStatusBar() and UpdateRecentFilesMenu() methods are both called from OpenMenu_Click().
So I started with...
With technology shaping our everyday lives, how could we not dig deeper?
Thurrott Premium delivers an honest and thorough perspective about the technologies we use and rely on everyday. Discover deeper content as a Premium member.