Skip to content

Commit 6bf9016

Browse files
committed
Fix copying on vs2015
1 parent 71b62b2 commit 6bf9016

File tree

1 file changed

+5
-1
lines changed

1 file changed

+5
-1
lines changed

VisualRust/RustClassifier.cs

Lines changed: 5 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -142,7 +142,11 @@ public IEnumerable<ITagSpan<ClassificationTag>> GetTags(NormalizedSnapshotSpanCo
142142
realStart = curSpan.Start.Position + token.StartIndex - multilinePrefixSize;
143143
realTokenLength = token.Text.Length;
144144
}
145-
var tokenSpan = new SnapshotSpan(curSpan.Snapshot, new Span(realStart, realTokenLength));
145+
// This little check is required because, we are sometimes called (eg. when copying in vs2015) on a span smaller than a whole line
146+
var tokenRange = new Span(realStart, realTokenLength).Intersection(curSpan);
147+
if (!tokenRange.HasValue)
148+
continue;
149+
var tokenSpan = new SnapshotSpan(curSpan.Snapshot, tokenRange.Value);
146150
yield return new TagSpan<ClassificationTag>(tokenSpan, new ClassificationTag(_rustTypes[Utils.LexerTokenToRustToken(token.Text, token.Type)]));
147151
}
148152
}

0 commit comments

Comments
 (0)