vladimir-djokic / TSLint

TSLint extension for Visual Studio 2017
7 stars 6 forks source link

CLR_EXCEPTION_System.ArgumentOutOfRangeException_80131502_TSLint.dll #18

Closed madskristensen closed 6 years ago

madskristensen commented 6 years ago

An undhandled ArgumentOutOfRangeException is thrown by tslint.dll and it has to do with the constructor of SnapshotSpan.

vladimir-djokic commented 6 years ago

It would be great if you could provide:

madskristensen commented 6 years ago

I don't have it installed. We saw the issue show up in the Watson logs for Visual Studio. I should have mentioned that in the initial bug, but I work on the Visual Studio extensibility team and that's the reason I opened the issue.

Usually when you get an ArgumentOutOfRangeException it is because you are creating a new SnapshotSpan where the length is longer than the underlying text buffer. A simple check around the place where you call the SnapshotSpan constructor to check the bounds should do the trick.

vladimir-djokic commented 6 years ago

In TsLintTagger.cs I have:

span = new SnapshotSpan(
    this._view.TextSnapshot,
    Span.FromBounds(startLine.Start + start, endLine.Start + end)
);

I could change it to something like:

var endBound = endLine.Start.Position + end;

if (endBound > this._view.TextSnapshot.Length)
    endBound = this._view.TextSnapshot.Length;

span = new SnapshotSpan(
    this._view.TextSnapshot,
    Span.FromBounds(startLine.Start + start, endBound)
);

But, I would really appreciate if you could provide mi with a .ts file that can exhibits the issue so I could properly test it.