Skip to content

Commit

Permalink
Fix #41 issue with double-load for sample
Browse files Browse the repository at this point in the history
  • Loading branch information
hawkerm committed Oct 21, 2021
1 parent ef6c876 commit 924c58e
Showing 1 changed file with 5 additions and 2 deletions.
7 changes: 5 additions & 2 deletions MonacoEditorTestApp/MainPage.xaml.cs
Original file line number Diff line number Diff line change
Expand Up @@ -199,11 +199,15 @@ await Editor.AddCommandAsync(KeyMod.CtrlCmd | KeyCode.KEY_U, async (args) =>
});

await Editor.AddActionAsync(new TestAction());

// we only need to fire loading once to initialize all our model/helpers
Editor.Loading -= Editor_Loading;
}

private void Editor_Loaded(object sender, RoutedEventArgs e)
{
// Ready for Display
Editor.Loaded -= Editor_Loaded;
}

private void Editor_OpenLinkRequest(WebView sender, WebViewNewWindowRequestedEventArgs args)
Expand Down Expand Up @@ -419,8 +423,6 @@ private void RemoveButton_Click(object sender, RoutedEventArgs e)
_myCondition = null;
Editor.KeyDown -= Editor_KeyDown;

Editor.Loaded -= Editor_Loaded;
Editor.Loading -= Editor_Loading;
Editor.OpenLinkRequested -= Editor_OpenLinkRequest;
Editor.InternalException -= Editor_InternalException;

Expand All @@ -444,6 +446,7 @@ private void RemoveButton_Click(object sender, RoutedEventArgs e)

Editor.KeyDown += Editor_KeyDown;

// Re-setup loading events for new instance
Editor.Loading += Editor_Loading;
Editor.Loaded += Editor_Loaded;
Editor.OpenLinkRequested += Editor_OpenLinkRequest;
Expand Down

0 comments on commit 924c58e

Please sign in to comment.