[Peek] Fix Monaco assets folder discovery #35925
Merged
+16
−22
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Summary of the Pull Request
The
MonacoHelper
class inFilePreviewCommon
handles locating the Monaco assets directory so the Monaco language file and template HTML file may be loaded. This PR corrects an issue wherebyGetRuntimeMonacoDirectory()
would return an incorrect folder location if an emptyINSTALLDIR\WinUI3Apps\Assets\Monaco
existed in addition to the correctINSTALLDIR\Assets\Monaco
location.PR Checklist
Detailed Description of the Pull Request / Additional comments
The function now does an explicit check to see if the calling assembly lies within the WinUI3Apps folder, and if so it navigates to the parent directory before continuing resolution of the assets path.
Validation Steps Performed
I reproduced the failure case by creating an empty
\AppData\Local\PowerToys\WinUI3Apps\Assets\Monaco
folder and then using Peek to preview files supported by Monaco, such as source code files. This confirmed the original report. After applying the fix and retesting, the same Peek previews correctly rendered the files.I also confirmed that the Explorer Preview Pane was unaffected, and also used Peek to view several non-Monaco files, such as images and PDFs, to confirm that other file types were still rendering without issue.
Before and After
Additional Info
A
WinUI3Apps\Assets\Monaco
folder is created when compiling the solution from source, and its contents look identical to the folder a level up in the hierarchy. I don't know if this is related to the original issue, but thought it was worth a mention.