Skip to content

Commit

Permalink
minor fixes
Browse files Browse the repository at this point in the history
  • Loading branch information
davidegiacometti committed Oct 5, 2024
1 parent 7fddb81 commit 2c21979
Show file tree
Hide file tree
Showing 2 changed files with 6 additions and 2 deletions.
Original file line number Diff line number Diff line change
Expand Up @@ -13,13 +13,13 @@
using Microsoft.UI.Xaml;
using Microsoft.UI.Xaml.Controls;
using Microsoft.Web.WebView2.Core;
using Windows.UI;

namespace RegistryPreviewUILib
{
[INotifyPropertyChanged]
public sealed partial class MonacoEditorControl : UserControl, IDisposable
{
private readonly string _tempFolderPath = Path.Combine(Environment.GetEnvironmentVariable("USERPROFILE"), @"\AppData\LocalLow\Microsoft\PowerToys\RegistryPreview-Temp");
private readonly Timer _textChangedThrottle;
private bool _textChangedThrottled;

Expand All @@ -33,7 +33,7 @@ public sealed partial class MonacoEditorControl : UserControl, IDisposable
public MonacoEditorControl()
{
InitializeComponent();
Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", _tempFolderPath, EnvironmentVariableTarget.Process);
Environment.SetEnvironmentVariable("WEBVIEW2_USER_DATA_FOLDER", MonacoHelper.TempFolderPath, EnvironmentVariableTarget.Process);

_textChangedThrottle = new Timer(250);
_textChangedThrottle.Elapsed += OnTextChangedThrottleElapsed;
Expand Down Expand Up @@ -63,6 +63,7 @@ private async void Browser_Loaded(object sender, RoutedEventArgs e)
IsLoading = true;

await Browser.EnsureCoreWebView2Async();
Browser.DefaultBackgroundColor = Color.FromArgb(0, 0, 0, 0);
Browser.CoreWebView2.NavigationCompleted += CoreWebView2_NavigationCompleted;
Browser.CoreWebView2.PermissionRequested += CoreWebView2_PermissionRequested;
Browser.CoreWebView2.Settings.AreDefaultScriptDialogsEnabled = false;
Expand Down
Original file line number Diff line number Diff line change
Expand Up @@ -2,6 +2,7 @@
// The Microsoft Corporation licenses this file to you under the MIT license.
// See the LICENSE file in the project root for more information.

using System;
using System.IO;
using System.Reflection;

Expand All @@ -14,6 +15,8 @@ public static class MonacoHelper
/// </summary>
public const string VirtualHostName = "PowerToysLocalMonaco";

public static string TempFolderPath { get; } = Path.Combine(Environment.GetFolderPath(Environment.SpecialFolder.UserProfile), @"AppData\LocalLow\Microsoft\PowerToys\RegistryPreview-Temp");

private static string _monacoDirectory;

public static string GetRuntimeMonacoDirectory()
Expand Down

0 comments on commit 2c21979

Please sign in to comment.