[PTRun]Add logs to check Web Browser detection (#18831)

* [PTRun]Add logs to check Web Browser detection

* Use proper initial value

* Add punctuation to the end of the log message
This commit is contained in:
Jaime Bernardo
2022-06-14 21:04:30 +01:00
committed by GitHub
parent f5f8861eac
commit 244394865f
2 changed files with 14 additions and 5 deletions

View File

@@ -150,7 +150,7 @@ namespace Wox.Infrastructure
{
if (string.IsNullOrEmpty(pattern))
{
Log.Warn("Trying to run OpenCommandInShell with an empty pattern. The default browser definition might have issues.", typeof(Helper));
Log.Warn($"Trying to run OpenCommandInShell with an empty pattern. The default browser definition might have issues. Path: '${path ?? string.Empty}' ; Arguments: '${arguments ?? string.Empty}' ; Working Directory: '${workingDir ?? string.Empty}'", typeof(Helper));
}
else if (pattern.Contains("%1", StringComparison.Ordinal))
{

View File

@@ -15,7 +15,6 @@ namespace Wox.Plugin.Common
public static class DefaultBrowserInfo
{
private static readonly object _updateLock = new object();
private static int _lastUpdateTickCount = -1;
/// <summary>Gets the path to the MS Edge browser executable.</summary>
public static string MSEdgePath =>
@@ -41,7 +40,11 @@ namespace Wox.Plugin.Common
public static bool IsDefaultBrowserSet { get => !string.IsNullOrEmpty(Path); }
public const int UpdateTimeout = 300;
public const long UpdateTimeout = 300;
private static long _lastUpdateTickCount = -UpdateTimeout;
private static bool haveIRanUpdateOnce;
/// <summary>
/// Updates only if at least more than 300ms has passed since the last update, to avoid multiple calls to <see cref="Update"/>.
@@ -49,8 +52,8 @@ namespace Wox.Plugin.Common
/// </summary>
public static void UpdateIfTimePassed()
{
int curTickCount = Environment.TickCount;
if (curTickCount - _lastUpdateTickCount > UpdateTimeout)
long curTickCount = Environment.TickCount64;
if (curTickCount - _lastUpdateTickCount >= UpdateTimeout)
{
_lastUpdateTickCount = curTickCount;
Update();
@@ -65,6 +68,12 @@ namespace Wox.Plugin.Common
{
lock (_updateLock)
{
if (!haveIRanUpdateOnce)
{
Log.Warn("I've tried updating the chosen Web Browser info at least once.", typeof(DefaultBrowserInfo));
haveIRanUpdateOnce = true;
}
try
{
string progId = GetRegistryValue(