Skip to content

Commit 5bf422a

Browse files
committed
Delay the initialization of the MarkdownViewer
1 parent d51c8bb commit 5bf422a

File tree

1 file changed

+13
-0
lines changed
  • QuickLook.Plugin/QuickLook.Plugin.MarkdownViewer

1 file changed

+13
-0
lines changed

QuickLook.Plugin/QuickLook.Plugin.MarkdownViewer/Plugin.cs

Lines changed: 13 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -31,6 +31,7 @@ namespace QuickLook.Plugin.MarkdownViewer;
3131

3232
public class Plugin : IViewer
3333
{
34+
private bool _isInitialized = false;
3435
private WebpagePanel? _panel;
3536
private string? _currentHtmlPath;
3637

@@ -58,6 +59,12 @@ public class Plugin : IViewer
5859
public int Priority => 0;
5960

6061
public void Init()
62+
{
63+
// Delayed initialization can speed up startup
64+
_isInitialized = false;
65+
}
66+
67+
public void InitializeResources()
6168
{
6269
// Initialize resources and handle versioning
6370
_resourceManager.InitializeResources();
@@ -78,6 +85,12 @@ public void Prepare(string path, ContextObject context)
7885

7986
public void View(string path, ContextObject context)
8087
{
88+
if (!_isInitialized)
89+
{
90+
_isInitialized = true;
91+
InitializeResources();
92+
}
93+
8194
_panel = new WebpagePanel();
8295
context.ViewerContent = _panel;
8396
context.Title = Path.GetFileName(path);

0 commit comments

Comments
 (0)