microsoft / RTVS

R Tools for Visual Studio.
MIT License
390 stars 118 forks source link

Snippets: Argument out of range #4251

Closed maxstreese closed 6 years ago

maxstreese commented 6 years ago

I am using Visual Studio version 15.5.2 with R Tools for Visual Studio version 1.3.31108.1213.

When I am using the function snippet (or any other I have tried) inside a R script the snippet body gets inserted correctly. Visual Studio does show an error message however: "Specified argument was out of the range of valid values. Parameter name: length". I did copy the definition of the snippet from GitHub (see here) and changed the language to CSharp to see if the definition is wrong. It does not seem to be because in a CSharp project the snippet inserts without an error message. Am I missing something?

grafik

karthiknadig commented 6 years ago

Thanks @MaxStreese, I was able to repro the bug.

System.ArgumentOutOfRangeException
  HResult=0x80131502
  Message=Specified argument was out of the range of valid values.
Parameter name: length
  Source=Microsoft.VisualStudio.Text.Data
  StackTrace:
   at Microsoft.VisualStudio.Text.Span..ctor(Int32 start, Int32 length)
   at Microsoft.VisualStudio.Text.Span.FromBounds(Int32 start, Int32 end)
   at Microsoft.VisualStudio.R.Package.Expansions.ExpansionClient.FormatSpan(IVsTextLines vsTextLines, TextSpan[] ts) in G:\GIT\RTVS\src\Package\Impl\Expansions\ExpansionClient.cs:line 177
   at Microsoft.VisualStudio.Editor.Implementation.Snippet.ExpansionFilter.BeginTemplateEditing()
   at Microsoft.VisualStudio.Editor.Implementation.Snippet.VsExpansionShim.InsertExpansionFromTemplate(ExpansionTemplate template, TextSpan tsInsertPos, IVsExpansionClient pExpansionClient, Guid guidLang, IVsExpansionSession& pSession)
   at Microsoft.VisualStudio.Editor.Implementation.Snippet.VsExpansionShim.InsertNamedExpansion(String bstrTitle, String bstrPath, TextSpan tsInsertPos, IVsExpansionClient pExpansionClient, Guid guidLang, Int32 fShowDisambiguationUI, IVsExpansionSession& pSession)
   at Microsoft.VisualStudio.Editor.Implementation.TextDocData.Microsoft.VisualStudio.TextManager.Interop.IVsExpansion.InsertNamedExpansion(String bstrTitle, String bstrPath, TextSpan tsInsertPos, IVsExpansionClient pExpansionClient, Guid guidLang, Int32 fShowDisambiguationUI, IVsExpansionSession& pSession)
   at Microsoft.VisualStudio.R.Package.Expansions.ExpansionClient.OnItemChosen(String pszTitle, String pszPath) in G:\GIT\RTVS\src\Package\Impl\Expansions\ExpansionClient.cs:line 220
   at Microsoft.VisualStudio.Editor.Implementation.Snippets.SnippetPicker.HandleSnippetCompletion(SnippetPickerSnippetCompletion completion)
   at Microsoft.VisualStudio.Editor.Implementation.Snippets.SnippetPicker.OnCompletionCommitted(Object sender, EventArgs e)
   at System.EventHandler.Invoke(Object sender, EventArgs e)
   at Microsoft.VisualStudio.Language.Intellisense.Implementation.CompletionSession.RaiseCommittedEvent()
   at Microsoft.VisualStudio.Language.Intellisense.Implementation.CompletionSession.Commit()
   at Microsoft.VisualStudio.Language.Intellisense.Implementation.DefaultCompletionSetPresenter.OnListBox_MouseDoubleClick(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs e)
   at System.Windows.Controls.Control.OnMouseDoubleClick(MouseButtonEventArgs e)
   at System.Windows.Controls.Control.HandleDoubleClick(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.ReRaiseEventAs(DependencyObject sender, RoutedEventArgs args, RoutedEvent newEvent)
   at System.Windows.UIElement.OnMouseDownThunk(Object sender, MouseButtonEventArgs e)
   at System.Windows.Input.MouseButtonEventArgs.InvokeEventHandler(Delegate genericHandler, Object genericTarget)
   at System.Windows.RoutedEventArgs.InvokeHandler(Delegate handler, Object target)
   at System.Windows.RoutedEventHandlerInfo.InvokeHandler(Object target, RoutedEventArgs routedEventArgs)
   at System.Windows.EventRoute.InvokeHandlersImpl(Object source, RoutedEventArgs args, Boolean reRaised)
   at System.Windows.UIElement.RaiseEventImpl(DependencyObject sender, RoutedEventArgs args)
   at System.Windows.UIElement.RaiseTrustedEvent(RoutedEventArgs args)
   at System.Windows.UIElement.RaiseEvent(RoutedEventArgs args, Boolean trusted)
   at System.Windows.Input.InputManager.ProcessStagingArea()
   at System.Windows.Input.InputManager.ProcessInput(InputEventArgs input)
   at System.Windows.Input.InputProviderSite.ReportInput(InputReport inputReport)
   at System.Windows.Interop.HwndMouseInputProvider.ReportInput(IntPtr hwnd, InputMode mode, Int32 timestamp, RawMouseActions actions, Int32 x, Int32 y, Int32 wheel)
   at System.Windows.Interop.HwndMouseInputProvider.FilterMessage(IntPtr hwnd, WindowMessage msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at System.Windows.Interop.HwndSource.InputFilterMessage(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndWrapper.WndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam, Boolean& handled)
   at MS.Win32.HwndSubclass.DispatcherCallbackOperation(Object o)
   at System.Windows.Threading.ExceptionWrapper.InternalRealCall(Delegate callback, Object args, Int32 numArgs)
   at System.Windows.Threading.ExceptionWrapper.TryCatchWhen(Object source, Delegate callback, Object args, Int32 numArgs, Delegate catchHandler)
   at System.Windows.Threading.Dispatcher.LegacyInvokeImpl(DispatcherPriority priority, TimeSpan timeout, Delegate method, Object args, Int32 numArgs)
   at MS.Win32.HwndSubclass.SubclassWndProc(IntPtr hwnd, Int32 msg, IntPtr wParam, IntPtr lParam)