Skip to content

Commit 06aaa80

Browse files
committed
Fixed an exception on startup
The GetProperty method throws when the key was missing and this was causing an unhandled exception on startup. Switched to TryGetProperty to avoid it
1 parent 32ef4d9 commit 06aaa80

1 file changed

Lines changed: 7 additions & 6 deletions

File tree

Plugin/Validation/EditorConfigErrorTag.cs

Lines changed: 7 additions & 6 deletions
Original file line numberDiff line numberDiff line change
@@ -29,16 +29,17 @@ public ITagger<T> CreateTagger<T>(ITextBuffer buffer) where T : ITag
2929
if (buffer == null)
3030
throw new ArgumentException("Buffer is null");
3131

32-
var errorlist = buffer.Properties.GetProperty(typeof(ErrorListProvider)) as ErrorListProvider;
33-
var view = buffer.Properties.GetProperty(typeof(IWpfTextView)) as IWpfTextView;
34-
32+
IWpfTextView view;
33+
ErrorListProvider errorlist;
3534
ITextDocument document;
36-
if (TextDocumentFactoryService.TryGetTextDocument(buffer, out document) && errorlist != null)
35+
if (!buffer.Properties.TryGetProperty(typeof(ErrorListProvider), out errorlist) ||
36+
!buffer.Properties.TryGetProperty(typeof(IWpfTextView), out view) ||
37+
!TextDocumentFactoryService.TryGetTextDocument(buffer, out document))
3738
{
38-
return new CheckTextErrorTagger(view, _classifierAggregatorService, errorlist, document) as ITagger<T>;
39+
return null;
3940
}
4041

41-
return null;
42+
return new CheckTextErrorTagger(view, _classifierAggregatorService, errorlist, document) as ITagger<T>;
4243
}
4344
}
4445

0 commit comments

Comments
 (0)