@@ -121,6 +121,8 @@ public partial class VisualAnalyzer : Form
121121
122122 private bool _EnableTrackBarZoom = true ;
123123
124+ private bool _Reloading = false ;
125+
124126 #region Constructors And Finalizers
125127
126128 /// <summary>
@@ -342,7 +344,9 @@ private void GuideAssemblyChanged(object sender, SyntaxHighlightingGuideReferenc
342344 private void GrammarAssemblyChanged ( object sender , GrammarReference e )
343345 {
344346 var grammar = FetchGrammarInternal ( e . AssemblyPath , e . GrammarName ) ;
347+ _Reloading = true ;
345348 SetGrammar ( grammar ) ;
349+ _Reloading = false ;
346350 ParseSource ( ) ;
347351 ColorizeTokens ( null ) ;
348352 }
@@ -522,7 +526,8 @@ private void ColorizeTokens(Range range)
522526 return ;
523527
524528 var tokensToColor = range == null ? _Tokens : FindTokensInRange ( _Tokens , range ) ;
525- _Highlighter . ColorizeTokens ( CodeEditor , _Registry , tokensToColor , GetErrorTokens ( ) ) ;
529+ if ( tokensToColor != null )
530+ _Highlighter . ColorizeTokens ( CodeEditor , _Registry , tokensToColor , GetErrorTokens ( ) ) ;
526531 }
527532
528533 private void ConfigureGraphWorker ( )
@@ -845,7 +850,7 @@ private void ParseMessageListView_Click(object sender, EventArgs e)
845850
846851 private void ParserRulesCombo_SelectedIndexChanged ( object sender , EventArgs e )
847852 {
848- if ( CmbRules . Items . Count > 0 )
853+ if ( CmbRules . Items . Count > 0 && ! _Reloading )
849854 {
850855 ParseSource ( ) ;
851856 ColorizeTokens ( null ) ;
0 commit comments