Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Preview Handler for developer files #15138

Merged
merged 118 commits into from
Jan 25, 2022
Merged

Preview Handler for developer files #15138

merged 118 commits into from
Jan 25, 2022

Conversation

Aaron-Junker
Copy link
Collaborator

@Aaron-Junker Aaron-Junker commented Dec 25, 2021

Summary of the Pull Request

What is this about:

Adds the preview handler for developer files. I open this PR, as integration is planned for january release (0.55). Here can things regarding the integration be discussed.

What needs to be done:

Clint's list

  • Add the font to signing
  • Sanity check this is a .NET 5 project
  • Remove Newtson and swap to System. JSON like all other libs
  • Swap to our common.ui theme system in 0.55 & removing the system.preview from signing
    • This would need to be a 0.56 item otherwise
  • Add 0.56 add unit test item (maybe this should just mimic maybe what the markdown previewer unit tests do?) (
    Add unit tests for developer preview #15749)
  • Test on blank VM to be sure installer installs for Webview2 runtime
  • Update notice.md

Aaron's list:

  • Adding solution to PowerToys
  • Add settings page (variables to set in settings.cs):
    • On/Off
    • Wrap lines On/Off
    • Drak mode/Light mode/Like system
  • Add translation for "file too big" and "loading" message
  • Modify installer:
    • Install filetypes
    • Ensure WebView2 installation
  • Add docs
  • (Optional) Add some of the filetypes from [Tracker] Suggestions for file formats for developer previewer #14957

Quality Checklist

Contributor License Agreement (CLA)

A CLA must be signed. If not, go over here and sign the CLA.

@htcfreek
Copy link
Collaborator

htcfreek commented Jan 25, 2022

@Aaron-Junker
Why not foreach when reading json. I see no reason to use a for loop.

Sory for not commenting in code. GitHub app can't load the file list. It's to big. 😅

@Aaron-Junker
Copy link
Collaborator Author

Aaron-Junker commented Jan 25, 2022

@Aaron-Junker Why not foreach when reading json. I see no reason to use a for loop.

Sory for not commenting in code. GitHub app can't load the file list. It's to big. 😅

I didn't knew foreach existed in C#. I thought this was a PHP only thing😅.

Will adress this for the next release.

@htcfreek
Copy link
Collaborator

@Aaron-Junker Why not foreach when reading json. I see no reason to use a for loop.

Sory for not commenting in code. GitHub app can't load the file list. It's to big. 😅

I didn't knew foreach existed in C#. I thought this was a PHP only thing😅.

Will adress this for the next release.

You can do something like for element in json. But don't ask me for the correct syntax. It isn't in my brain at the moment. 😅

Copy link
Collaborator

@stefansjfw stefansjfw left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I took another look, but basically I already did a review while integrating monaco into powertoys. I found few minor issues. Would be nice to solve right now, but non-blocking imho

EDIT : Please don't merge, wait for at least one more approve

{
try
{
JsonDocument a = JsonDocument.Parse(File.ReadAllText(Settings.AssemblyDirectory + "\\languages.json"));
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

nit: a not a very descriptive var name..

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Forgot this placeholder 😅

/// This event cancels every navigation inside the webview
/// </summary>
[STAThread]
private void NavigationStarted(object sender, CoreWebView2NavigationStartingEventArgs e)
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

this is never called?

Copy link
Collaborator Author

@Aaron-Junker Aaron-Junker Jan 25, 2022

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Technically it shpuld be registered as eventhandler. But I'm not 100% sure

Copy link
Collaborator

@jaimecbernardo jaimecbernardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Left some comments.
After building and installing, I can't seem to open settings;

Description: A .NET Core application failed.
Application: PowerToys.Settings.exe
Path: C:\Program Files\PowerToys\Settings\PowerToys.Settings.exe
Message: Error:
  An assembly specified in the application dependencies manifest (PowerToys.Settings.deps.json) was not found:
    package: 'Microsoft.Web.WebView2.Core', version: '255.255.255.255'
    path: 'Microsoft.Web.WebView2.Core.winmd'

I'm assuming this was caused by #15707

@@ -7,7 +7,7 @@ Param(
)

$DirPath = $targetDir; #this file is in pipeline, we need root.
$items = Get-ChildItem -Path $DirPath -File -Include *.exe,*.dll -Recurse -Force -ErrorAction SilentlyContinue
$items = Get-ChildItem -Path $DirPath -File -Include *.exe,*.dll,*.ttf -Recurse -Force -ErrorAction SilentlyContinue
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Do ttf files need to be signed?

Copy link
Collaborator Author

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@crutkas said yes. He will look into it in a future PR

Copy link
Contributor

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Should they be OTF instead?

@@ -127,7 +128,7 @@
<Custom Action="TelemetryLogUninstallSuccess" After="InstallFinalize">
Installed and (NOT UPGRADINGPRODUCTCODE) AND (REMOVE="ALL")
</Custom>
<Custom Action="UnApplyModulesRegistryChangeSets" Before="InstallFinalize">
<Custom Action="UnApplyModulesRegistryChangeSets" Before="RemoveFiles">
Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Why did this change?

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I think because we need some of the files we then remove in the next step.

Copy link
Collaborator

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

@htcfreek is correct, to unapply the monaco handler registry changes from CA installer, we need to read languages.json file to get a list of extensions the handler is used for.

Copy link
Collaborator

@yuyoyuppe yuyoyuppe left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

I've been mostly focused on installer/registry-related changes, and they look good to me.

@crutkas
Copy link
Member

crutkas commented Jan 25, 2022

@jaimecbernardo that is saying settings is requesting WebView2 which shouldn't be needed for settings app

@stefansjfw
Copy link
Collaborator

@jaimecbernardo that is saying settings is requesting WebView2 which shouldn't be needed for settings app

I think it's related to what @niels9001 did with bumping versions.. I'll revert those.. We can deal with it later

@htcfreek
Copy link
Collaborator

@jaimecbernardo that is saying settings is requesting WebView2 which shouldn't be needed for settings app

Maybe it's this change in v2.8: microsoft/microsoft-ui-xaml#5929

@crutkas
Copy link
Member

crutkas commented Jan 25, 2022

once @jaimecbernardo / @stefansjfw approve, the merge can be all yours. Great job

@stefansjfw
Copy link
Collaborator

@jaimecbernardo I pushed revert commits, can you give it another tests to doublecheck it? After that , if everything is ok, It's good to go IMHO

Copy link
Collaborator

@jaimecbernardo jaimecbernardo left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

LGTM now!
Great work here!
Thanks a lot for this!
Feel free to squash merge @Aaron-Junker .

@crutkas
Copy link
Member

crutkas commented Jan 25, 2022

🚀🚀🚀🔥🔥🔥🔥🚀🚀🚀🚀🚀🚀🔥🔥🔥🔥🔥

🚢🚢🚢🚢🚢

@Aaron-Junker Aaron-Junker merged commit 39b98da into main Jan 25, 2022
@Aaron-Junker Aaron-Junker deleted the feature/monacoPreviewPane branch January 25, 2022 20:02
@stefansjfw
Copy link
Collaborator

Niiiiceee! 🎉🎉

@htcfreek
Copy link
Collaborator

Coooool. It's ready to use now. 🚀👏

@chip33
Copy link

chip33 commented Feb 1, 2022

Just trying this with v0.55.0.
I am wondering why it does not support commonly used scripting files in windows such as .vbs , .ahk, .au3. Is there a settings file where we can add these new filetypes?
Also some filetypes such as .reg and many of "PerceivedType"="text" show in the Preview pane with a white background when using a dark theme. Is there a setting to change this?

Really fantastic work to achieve this. It has been missing in Windows for so long.

@Aaron-Junker
Copy link
Collaborator Author

Just trying this with v0.55.0.
I am wondering why it does not support commonly used scripting files in windows such as .vbs , .ahk, .au3. Is there a settings file where we can add these new filetypes?
Also some filetypes such as .reg and many of "PerceivedType"="text" show in the Preview pane with a white background when using a dark theme. Is there a setting to change this?

Currently there's not an easy way to add costum types.
I've added your suggestion to #14957. What do you mean with "PerceivedType"="text"?

Really fantastic work to achieve this. It has been missing in Windows for so long.

Thank you!

@chip33
Copy link

chip33 commented Feb 1, 2022

Thanks for adding the request!
"PerceivedType"="text" is a registry setting applied natively to many filetypes.

[HKEY_CLASSES_ROOT\.text] "PerceivedType"="text"

or

[HKEY_CLASSES_ROOT\.sql] "PerceivedType"="text"

Filetypes of PerceivedType=text always show in the Preview pane so It was often recommended to add PerceivedType=text to a filetype as a hacky workaround to make it visible in the Preview pane.

With Preview Handler for developer files .sql shows with syntax highlighting as a named filetype in your code but .text and many others of PerceivedType=text still show as the default Windows white preview pane.
It would be good if they could also show the same dark preview as filetype .txt.

@Aaron-Junker
Copy link
Collaborator Author

Thanks for adding the request!
"PerceivedType"="text" is a registry setting applied natively to many filetypes.

[HKEY_CLASSES_ROOT\.text] "PerceivedType"="text"

or

[HKEY_CLASSES_ROOT\.sql] "PerceivedType"="text"

Filetypes of PerceivedType=text always show in the Preview pane so It was often recommended to add PerceivedType=text to a filetype as a hacky workaround to make it visible in the Preview pane.

With Preview Handler for developer files .sql shows with syntax highlighting as a named filetype in your code but .text and many others of PerceivedType=text still show as the default Windows white preview pane.
It would be good if they could also show the same dark preview as filetype .txt.

You could manually copy the registry key of a file type that uses the new design to another one.

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.

None yet