From 315059fc3be030cdd3b69b846d3f09ac108fffd1 Mon Sep 17 00:00:00 2001
From: Jaime Bernardo <jaime@janeasystems.com>
Date: Wed, 15 Jan 2025 15:39:30 +0000
Subject: [PATCH] [Peek]Fix using the correct Monaco assets at runtime (#36890)

---
 src/common/FilePreviewCommon/MonacoHelper.cs | 4 ++++
 1 file changed, 4 insertions(+)

diff --git a/src/common/FilePreviewCommon/MonacoHelper.cs b/src/common/FilePreviewCommon/MonacoHelper.cs
index 303cacbde287..3aff51fe6ec0 100644
--- a/src/common/FilePreviewCommon/MonacoHelper.cs
+++ b/src/common/FilePreviewCommon/MonacoHelper.cs
@@ -38,7 +38,11 @@ private static string GetRuntimeMonacoDirectory()
         {
             string baseDirectory = AppContext.BaseDirectory ?? string.Empty;
 
+            // AppContext.BaseDirectory returns a stray \\ so we want to remove that.
+            baseDirectory = Path.TrimEndingDirectorySeparator(baseDirectory);
+
             // If the executable is within "WinUI3Apps", correct the path first.
+            // The idea of GetFileName here is getting the last directory in the path.
             if (Path.GetFileName(baseDirectory) == "WinUI3Apps")
             {
                 baseDirectory = Path.Combine(baseDirectory, "..");