madskristensen / Tweakster

A Visual Studio extension
Apache License 2.0
240 stars 23 forks source link

ArgumentOutOfRangeException when Copying Text #58

Closed kylegregory closed 3 years ago

kylegregory commented 3 years ago

From the Activity Log:

System.ArgumentOutOfRangeException: Specified argument was out of the range of valid values. Parameter name: length at Microsoft.VisualStudio.Text.Span..ctor(Int32 start, Int32 length) at Microsoft.VisualStudio.Text.SnapshotSpan..ctor(ITextSnapshot snapshot, Int32 start, Int32 length) at Tweakster.Tweaks.Editor.CopyWithoutIndentation.ExecuteCommand(CopyCommandArgs args, CommandExecutionContext executionContext) in C:\projects\tweakster\src\Tweaks\Editor\CopyWithoutIndentation.cs:line 77 at Microsoft.VisualStudio.UI.Text.Commanding.Implementation.EditorCommandHandlerService.<>c__DisplayClass14_11.<ExecuteStartingAtIndex>b__0() at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.CallExtensionPoint(Object errorSource, Action call, Predicate1 exceptionFilter) --- End of stack trace from previous location where exception was thrown --- at Microsoft.VisualStudio.Telemetry.WindowsErrorReporting.WatsonReport.GetClrWatsonExceptionInfo(Exception exceptionObject)

madskristensen commented 3 years ago

Thanks!!!

Can you please share steps to reproduce? What text was in the buffer and what was your selection when you hit the copy command?

kylegregory commented 3 years ago

Looks like it happens once upon reopening VS. Copy/Pasting C# code in a normal .cs file. I'll try and see if it happens a second time after restart and update. I typically copy upwards from the final semicolon to the line just before the the start of the text copy. My selected text (assuming what would be in the buffer after issuing the copy command) would be the following from Start Selection -->> to <<--End Selection. It would include the line return as well as any spaces/tabs to the next line before my text to copy:

            Events = Secondary == null ? new List() : new List { Secondary.Value };Start Selection-->>
            var occurrences = Event.GetAllOccurrences(MyClass.Key ?? 0);
            EventsList = new GroupSelectList(occurrences, "Key", "Name", "EventName", Events);<<-- End Selection