Visual Studio Editor CC/Syntax Highlight Crashes

I have seen this issue in VS 2013 Pro and 2015 Pro with both Elements 8.1 and 8.2 (latest beta). I’ll be typing along in VS and while rearranging braces or parentheses (the auto placement of these seems to be broken, but that’s another issue) when an error dialog pops up saying that “An exception has been encountered” and to check the ActivityLog.xml for details. Following is the last element in that log.

  <entry>
    <record>912</record>
    <time>2015/09/21 23:12:56.029</time>
    <type>Error</type>
    <source>Editor or Editor Extension</source>
    <description>System.ArgumentOutOfRangeException: startIndex cannot be larger than length of string.&#x000D;&#x000A;Parameter name: startIndex&#x000D;&#x000A;   at System.String.Substring(Int32 startIndex, Int32 length)&#x000D;&#x000A;   at System.String.Substring(Int32 startIndex)&#x000D;&#x000A;   at RemObjects.Oxygene.Code.BaseParser.A(Int32 , Int32 , String , String )&#x000D;&#x000A;   at RemObjects.Oxygene.Code.Compiler.CodeCompletionCompiler.UpdateFileUpdate(BaseParser aParser, Int32 aOffset, Int32 aCount, String aData, String aCompletedText, Boolean aDoUpdateEvent)&#x000D;&#x000A;   at RemObjects.Oxygene.Code.Compiler.Compiler.UpdateFileUpdate(String , Int32 , Int32 , String , String )&#x000D;&#x000A;   at RemObjects.Oxygene.VisualStudio.Editor.OxygeneClassifier.fBuffer_Changed(Object sender, TextContentChangedEventArgs e)&#x000D;&#x000A;   at Microsoft.VisualStudio.Text.Utilities.GuardedOperations.RaiseEvent[TArgs](Object sender, EventHandler`1 eventHandlers, TArgs args)</description>
  </entry>

Also, in case it’s helpful, in both of my installs, I’m using the full Visual Studio Pro, not the Visual Studio Shell.

OK, I found that if you unselect “Automatic parenthesis completion”, the auto-placement and auto-indenting for braces seems to work correctly.

I just upgraded to Beta .1849 and haven’t gotten the CC exception, yet. Fingers crossed that issue was fixed.

oke that is curious. Any idea what you are doing when it does fail? (i’ve yet to see this behavior so it must be something I am not doing that you are)

I haven’t been able to reproduce it on demand yet. It seems like it’s related to whatever plugin puts red squigely lines under code that has an error. I believe it happens when I get the error lines to appear on the closing braces of a class. I hover over the error to see what it says and then when I go to type more, I get the exception message box and CC/auto-format/auto-indent no longer work. I pasted the exception that is thrown in the first message in this thread if that helps.

hmm oke. Is this in a file in a shared project or in a regular project? What language?

It is in a shared project and in RemObjects C#. It seems to be important that the file is shared and that the File Switcher Display is displaying. I have the file shared between a .Net and Java project.

I’ve finally found a way to reproduce it:

  1. Create a shared project in RO C#.
  2. Create a .Net and Java library project that references the shared project.
  3. In the shared project create a class called Optional.
  4. Make sure the File Switcher is active.
  5. Type in the code as shown in the attached image.
  6. After typing in the constructor, you should see a red squigly highlight as shown in the image.
  7. Hover the mouse over the error squigley to see what the error is as shown in the image.
  8. Go to type some more in the editor and an exception is thrown. Now CC/Auto-indent/etc. will not work.

I’ve created a separate thread for the broken brace placement that I mentioned in the first post. It is here: Bug with Automatic Parenthesis Completion

Thanks, logged as bugs://73278

bugs://73278 got closed with status fixed.