Skip to content

Commit 2ef052e

Browse files
committed
Fix for GLyph creating tag spans with length 0 or null buffers
1 parent 73a6ffd commit 2ef052e

File tree

1 file changed

+11
-1
lines changed

1 file changed

+11
-1
lines changed

CompileScore/Shared/Editor/Glyph/ScoreGlyphTagger.cs

Lines changed: 11 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -92,6 +92,9 @@ private void OnDataChanged()
9292

9393
private void RefreshTags()
9494
{
95+
if (_buffer.CurrentSnapshot == null || _buffer.CurrentSnapshot.Length <= 0)
96+
return;
97+
9598
CreateTrackingSpans();
9699
TagsChanged?.Invoke(this, new SnapshotSpanEventArgs(new SnapshotSpan(_buffer.CurrentSnapshot, new Span(0, _buffer.CurrentSnapshot.Length - 1))));
97100
}
@@ -105,7 +108,14 @@ private void CreateTrackingSpans()
105108
CompilerData.Instance.Hydrate(CompilerData.HydrateFlag.Main);
106109

107110
var currentSnapshot = _buffer.CurrentSnapshot;
108-
MatchCollection matches = Regex.Matches(currentSnapshot.GetText(), EditorUtils.IncludeRegex);
111+
112+
if (currentSnapshot == null) return;
113+
114+
string currentSnapshotText = currentSnapshot.GetText();
115+
116+
if (currentSnapshotText == null) return;
117+
118+
MatchCollection matches = Regex.Matches(currentSnapshotText, EditorUtils.IncludeRegex);
109119
foreach (Match match in matches)
110120
{
111121
if (match.Success)

0 commit comments

Comments
 (0)