Skip to content

Commit 23dc3cb

Browse files
committed
Ignored text views without text document property.
1 parent 73795b3 commit 23dc3cb

1 file changed

Lines changed: 7 additions & 1 deletion

File tree

src/GtmExtension/GtmListener.cs

Lines changed: 7 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,7 +92,11 @@ private void ShowError(string message)
9292

9393
private string GetFilePath(ITextView textView)
9494
{
95-
return textView.TextBuffer.Properties.GetProperty<ITextDocument>(typeof(ITextDocument)).FilePath;
95+
if (textView.TextBuffer.Properties.TryGetProperty(typeof(ITextDocument), out ITextDocument doc))
96+
{
97+
return doc.FilePath;
98+
}
99+
return null;
96100
}
97101

98102
private void GetService<T>(ref T field) { field = GetService<T>(); }
@@ -237,6 +241,8 @@ private void Initialize()
237241
}
238242
private void Update(string path, bool force = false)
239243
{
244+
if (path == null) { return; }
245+
240246
ThreadHelper.ThrowIfNotOnUIThread();
241247

242248
var time = DateTime.Now;

0 commit comments

Comments
 (0)