MemberList.Show throws when new text is shorter than old tex

SyntaxEditor for Windows Forms Forum

Posted 19 years ago by jsu2srv - Boston, MA
Avatar
(I am using version 2.5.0150 of SyntaxEditor and VS.NET 2003.)

Can someone tell me why this is happening? If I type a long method name in (that doesn't have a match in the IntelliPrompt MemberList control), and then select a member that is shorter than the text I typed, I get the following exception:

An unhandled exception of type 'System.ArgumentException' occurred in actiprosoftware.syntaxeditor.dll

Additional information: The offset '0' added to the length '24' must be less than or equal to the count of characters in the document.

My code is triggered on every key press in an identifier and looks like this:

private void ShowOptions(IntelliPromptMemberListItem[] options, int offset, int length)
{
if (editor.IntelliPrompt.MemberList.Visible)
return;
editor.IntelliPrompt.MemberList.Clear();
editor.IntelliPrompt.MemberList.AddRange(options);
editor.IntelliPrompt.MemberList.Show(offset, length);
}

If I type the following text into the editor:

asdfasfdasdfasdfasdfasdf

and then select the value "field" from the member list, I get the above exception.

Here is a full stack trace:

Unhandled Exception: System.ArgumentException: The offset '0' added to the length '24' must be less than or equal to the count of characters in the document.
at ActiproSoftware.SyntaxEditor.Document._2(Int32 , Int32 )
at ActiproSoftware.SyntaxEditor.Document.GetSubstring(Int32 offset, Int32 length)
at ActiproSoftware.SyntaxEditor.IntelliPromptMemberList.ActiproSoftware.SyntaxEditor.ISyntaxEditorEditModeHandler.OnSelectionChanged(SelectionEventArgs e)
at ActiproSoftware.SyntaxEditor.SyntaxEditor._1(SelectionEventArgs )
at ActiproSoftware.SyntaxEditor.EditorView._1(Object , SelectionEventArgs )
at ActiproSoftware.SyntaxEditor.Selection._1(SelectionEventArgs )
at ActiproSoftware.SyntaxEditor.Selection._1(Boolean )
at ActiproSoftware.SyntaxEditor.Selection._1(DocumentModificationEventArgs )
at ActiproSoftware.SyntaxEditor.SyntaxEditor._2(Object , DocumentModificationEventArgs )
at ActiproSoftware.SyntaxEditor.Document._1(DocumentModificationEventArgs )
at ActiproSoftware.SyntaxEditor.Document._2(DocumentModificationEventArgs )
at ActiproSoftware.SyntaxEditor.Document._1(DocumentModification )
at ActiproSoftware.SyntaxEditor.Document._1(DocumentModificationType , Int32 , Int32 , String )
at ActiproSoftware.SyntaxEditor.Document.UndoableInsert(DocumentModificationType type, Int32 offset, Int32 length, String text)
at ActiproSoftware.SyntaxEditor.IntelliPromptMemberList._3()
at _9.OnHiding(EventArgs e)
at ActiproSoftware.WinUICore.PopupControl.OnVisibleChanged(EventArgs e)
at System.Windows.Forms.Control.WmShowWindow(Message& m)
at System.Windows.Forms.Control.WndProc(Message& m)
at System.Windows.Forms.ScrollableControl.WndProc(Message& m)
at System.Windows.Forms.ContainerControl.WndProc(Message& m)
at System.Windows.Forms.Form.WmShowWindow(Message& m)
at System.Windows.Forms.Form.WndProc(Message& m)
at ActiproSoftware.WinUICore.PopupControl.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.SafeNativeMethods.ShowWindow(HandleRef hWnd, Int32 nCmdShow)
at System.Windows.Forms.Control.SetVisibleCore(Boolean value)
at System.Windows.Forms.Form.SetVisibleCore(Boolean value)
at ActiproSoftware.WinUICore.PopupControl.SetVisibleCore(Boolean visible)
at System.Windows.Forms.Control.set_Visible(Boolean value)
at System.Windows.Forms.Control.Hide()
at ActiproSoftware.WinUICore.PopupControl.HidePopup()
at ActiproSoftware.SyntaxEditor.IntelliPromptMemberList.Complete()
at _9._2(Object , EventArgs )
at System.Windows.Forms.Control.OnDoubleClick(EventArgs e)
at System.Windows.Forms.ListBox.WndProc(Message& m)
at _8.WndProc(Message& m)
at System.Windows.Forms.ControlNativeWindow.OnMessage(Message& m)
at System.Windows.Forms.ControlNativeWindow.WndProc(Message& m)
at System.Windows.Forms.NativeWindow.DebuggableCallback(IntPtr hWnd, Int32 msg, IntPtr wparam, IntPtr lparam)
at System.Windows.Forms.UnsafeNativeMethods.DispatchMessageW(MSG& msg)
at System.Windows.Forms.ComponentManager.System.Windows.Forms.UnsafeNativeMethods+IMsoComponentManager.FPushMessageLoop(Int32 dwComponentID, Int32 reason, Int32 pvLoopData)
at System.Windows.Forms.ThreadContext.RunMessageLoopInner(Int32 reason, ApplicationContext context)
at System.Windows.Forms.ThreadContext.RunMessageLoop(Int32 reason, ApplicationContext context)
at System.Windows.Forms.Application.Run(Form mainForm)
at RichExprEdit.Form1.Main() in s:\si\src\richexpredit\richexpredit\form1.cs:line 292The program '[4104] RichExprEdit.exe' has exited with code 0 (0x0).

Comments (5)

Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Could you possibly email me code to add to the sample project to duplicate the exception?


Actipro Software Support

Posted 19 years ago by jsu2srv - Boston, MA
Avatar
I was able to reproduce using the CSharp sample application without code modification:

1. start sample app
2. click "New Document" button to create an empty file
3. type "bool." The "." pops up the member list.
4. Now type "Equals" (WITHOUT selecting the item in the member list)
5. Now select "Parse" from the member list. This triggers the exception:

An unhandled exception of type 'System.ArgumentException' occurred in system.windows.forms.dll

Additional information: The offset '5' added to the length '6' must be less than or equal to the count of characters in the document.
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Thanks for the details... this is now fixed for the next maintenance release.


Actipro Software Support

Posted 19 years ago by jsu2srv - Boston, MA
Avatar
Great! Thanks. When will the next maintainence release be available?
Posted 19 years ago by Actipro Software Support - Cleveland, OH, USA
Avatar
Probably this weekend or next.


Actipro Software Support

The latest build of this product (v24.1.0) was released 1 month ago, which was after the last post in this thread.

Add Comment

Please log in to a validated account to post comments.