Commit
This commit does not belong to any branch on this repository, and may belong to a fork outside of the repository.
[MonacoPreviewHandler][Settings] Resolve preview handler race (#16180)
* Register .markdown with the correct handler * Fix spelling * Move file name extensions from "expect.txt" to "excludes.txt" * Revert "Move file name extensions from "expect.txt" to "excludes.txt"" This reverts commit 710d5a4. I must have misunderstood the instructions. * Revert "Register .markdown with the correct handler" This reverts commit 5c37b00. * Work in progress * Code ready for testing * Update excludes.txt * Update excludes.txt * Update modulesRegistry.h * Update modulesRegistry.h For the want of an exclamation mark, a kingdom is lost! * Update modulesRegistry.h * Work on modulesRegistry.h per code review in 16180 Removed all previous exclusions from Monaco preview handler. Added a new exclusion: SVGZ. It's a binary file that Monaco cannot, in any meaningful way, read. * Update expect.txt * Update accessory files * Disable machine-wide checks for performance reasons
- Loading branch information
1 parent
b415e79
commit 05d5649
Showing
5 changed files
with
121 additions
and
17 deletions.
There are no files selected for viewing
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
76 changes: 76 additions & 0 deletions
76
tools/Verification scripts/Check preview handler registration.ps1
This file contains bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Original file line number | Diff line number | Diff line change |
---|---|---|
@@ -0,0 +1,76 @@ | ||
#Requires -Version 7.2 | ||
|
||
using namespace System.Management.Automation | ||
|
||
[CmdletBinding()] | ||
param() | ||
|
||
function PublicStaticVoidMain { | ||
[CmdletBinding()] | ||
param () | ||
|
||
class TypeHandlerData { | ||
[String] $Name | ||
[String] $CurrentUserHandler | ||
[String] $MachineWideHandler | ||
} | ||
|
||
[String[]]$TypesToCheck = @(".markdown", ".mdtext", ".mdtxt", ".mdown", ".mkdn", ".mdwn", ".mkd", ".md", ".svg", ".svgz", ".pdf", ".gcode", ".stl", ".txt", ".ini") | ||
$IPREVIEW_HANDLER_CLSID = '{8895b1c6-b41f-4c1c-a562-0d564250836f}' | ||
$PowerToysHandlers = @{ | ||
'{07665729-6243-4746-95b7-79579308d1b2}' = "PowerToys PDF handler" | ||
'{ddee2b8a-6807-48a6-bb20-2338174ff779}' = "PowerToys SVG handler" | ||
'{ec52dea8-7c9f-4130-a77b-1737d0418507}' = "PowerToys GCode handler" | ||
'{45769bcc-e8fd-42d0-947e-02beef77a1f5}' = "PowerToys Markdown handler" | ||
'{afbd5a44-2520-4ae0-9224-6cfce8fe4400}' = "PowerToys Monaco fallback handler" | ||
'{DC6EFB56-9CFA-464D-8880-44885D7DC193}' = "Adobe Acrobat DC" | ||
} | ||
|
||
function ResolveHandlerGUIDtoName { | ||
param ( | ||
[Parameter(Mandatory, Position = 0)] | ||
[String] $GUID | ||
) | ||
return $PowerToysHandlers[$GUID] ?? $GUID | ||
} | ||
|
||
function WriteMyProgress { | ||
param ( | ||
[Parameter(Mandatory, Position=0)] [Int32] $ItemsPending, | ||
[Parameter(Mandatory, Position=1)] [Int32] $ItemsTotal, | ||
[switch] $Completed | ||
) | ||
[Int32] $PercentComplete = ($ItemsPending / $ItemsTotal) * 100 | ||
if ($PercentComplete -lt 1) { $PercentComplete = 1} | ||
Write-Progress -Activity 'Querying Windows Registry' -Status "$ItemsPending of $ItemsTotal" -PercentComplete $PercentComplete -Completed:$Completed | ||
} | ||
|
||
$ItemsTotal = $TypesToCheck.Count * 2 | ||
$ItemsPending = 0 | ||
WriteMyProgress 0 $ItemsTotal | ||
|
||
$CheckResults = New-Object -TypeName 'System.Collections.Generic.List[TypeHandlerData]' | ||
foreach ($item in $TypesToCheck) { | ||
$CurrentUserGUID = Get-ItemPropertyValue -Path "HKCU://Software/Classes/$item/shellex/$IPREVIEW_HANDLER_CLSID" -Name '(default)' -ErrorAction SilentlyContinue | ||
$ItemsPending += 1 | ||
WriteMyProgress $ItemsPending $ItemsTotal | ||
|
||
$MachineWideGUID = "Didn't check" | ||
# $MachineWideGUID = Get-ItemPropertyValue -Path "HKLM://Software/Classes/$item/shellex/$IPREVIEW_HANDLER_CLSID" -Name '(default)' -ErrorAction SilentlyContinue | ||
$ItemsPending += 1 | ||
WriteMyProgress $ItemsPending $ItemsTotal | ||
|
||
$temp = New-Object -TypeName TypeHandlerData -Property @{ | ||
Name = $item | ||
CurrentUserHandler = ($null -eq $CurrentUserGUID) ? "Nothing" : (ResolveHandlerGUIDtoName ($CurrentUserGUID)) | ||
MachineWideHandler = ($null -eq $MachineWideGUID) ? "Nothing" : (ResolveHandlerGUIDtoName ($MachineWideGUID)) | ||
} | ||
$CheckResults.Add($temp) | ||
|
||
Clear-Variable 'CurrentUserGUID', 'MachineWideGUID' | ||
} | ||
WriteMyProgress $ItemsPending $ItemsTotal -Completed | ||
$CheckResults | Format-Table -AutoSize | ||
} | ||
|
||
PublicStaticVoidMain |