@@ -267,7 +267,9 @@ void AddInsertionTextBlock(int start, int end, string line)
267267 {
268268 string remainder = line . Substring ( start , end - start ) ;
269269 var textBlock = CreateTextBox ( remainder , greyBrush ) ;
270- GetTagger ( ) . UpdateAdornment ( textBlock ) ;
270+ var inlineTagger = GetTagger ( ) ;
271+ if ( inlineTagger == null ) { return ; }
272+ inlineTagger . UpdateAdornment ( textBlock ) ;
271273 }
272274 catch ( ArgumentOutOfRangeException )
273275 {
@@ -281,7 +283,9 @@ public void UpdateAdornment(IWpfTextView view, string userText, int suggestionSt
281283 try
282284 {
283285 stackPanel . Children . Clear ( ) ;
284- GetTagger ( ) . ClearAdornment ( ) ;
286+ var inlineTagger = GetTagger ( ) ;
287+ if ( inlineTagger == null ) { return ; }
288+ inlineTagger . ClearAdornment ( ) ;
285289 for ( int i = suggestionStart ; i < suggestion . Item2 . Length ; i ++ )
286290 {
287291 string line = suggestion . Item2 [ i ] ;
@@ -363,6 +367,7 @@ private void OnSizeChanged(object sender, EventArgs e)
363367 var start = view . TextViewLines . GetCharacterBounds ( snapshotLine . Start ) ;
364368
365369 InlineGreyTextTagger inlineTagger = GetTagger ( ) ;
370+ if ( inlineTagger == null ) { return ; }
366371 inlineTagger . FormatText ( GetTextFormat ( ) ) ;
367372
368373 if ( stackPanel . Children . Count > 0 )
@@ -516,6 +521,7 @@ public void ClearSuggestion()
516521 {
517522 if ( ! showSuggestion ) return ;
518523 InlineGreyTextTagger inlineTagger = GetTagger ( ) ;
524+ if ( inlineTagger == null ) { return ; }
519525 inlineTagger . ClearAdornment ( ) ;
520526 inlineTagger . MarkDirty ( ) ;
521527 suggestion = null ;
@@ -536,7 +542,9 @@ void MarkDirty()
536542 {
537543 try
538544 {
539- GetTagger ( ) . MarkDirty ( ) ;
545+ InlineGreyTextTagger inlineTagger = GetTagger ( ) ;
546+ if ( inlineTagger == null ) { return ; }
547+ inlineTagger . MarkDirty ( ) ;
540548 ITextSnapshot newSnapshot = buffer . CurrentSnapshot ;
541549 this . snapshot = newSnapshot ;
542550
0 commit comments