Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.

Bug 319730

Summary: IllegalArgumentException while editing file with Xtext Editor
Product: [Modeling] TMF Reporter: Ludwig Straub <shadowrobe>
Component: XtextAssignee: Project Inbox <tmf.xtext-inbox>
Status: CLOSED FIXED QA Contact:
Severity: normal    
Priority: P3 CC: benjamin.schwertfeger, sebastian.zarnekow
Version: unspecifiedFlags: sebastian.zarnekow: helios+
Target Milestone: SR1   
Hardware: PC   
OS: Windows XP   
Whiteboard:
Attachments:
Description Flags
archive with all files to reproduce the issue
none
Patch for HEAD on 2010-07-28 on o.e.x.ui none

Description Ludwig Straub CLA 2010-07-13 10:28:29 EDT
Build Identifier: 20100617-1415

In certain circumstances the generated dsl editor throws an IllegalArgumentException resulting either in a corrupt editor or a corrupt in-memory-model.
(Exception detail: see attachment: "Exception.txt" in "xtext_issue.zip")

Reproducible: Always

Steps to Reproduce:
1. extract attachment
2. use org.xtext.example.mydsl + org.xtext.example.mydsl.ui from archive to launch an eclipse application
3. load project "mydsl" from archive in workspace
4. edit the file "test.mydsl" in imported project as follows:
a) remove the "(" of line 3
b) clean all characters of line 2
c) enter "(" in line 2
d) as soon as you try to enter ")" after the "(" in line 2, the Exception occurs and the ")" is not printed.

Note: If you then save the model and reopen the file, the ")" does exist.
Comment 1 Ludwig Straub CLA 2010-07-13 10:30:24 EDT
Created attachment 174153 [details]
archive with all files to reproduce the issue
Comment 2 Benjamin Schwertfeger CLA 2010-07-28 11:04:35 EDT
The SingleLineTerminalsStrategy tries to overwrite always one character more in #handleInsertRightTerminal, if the number of right and left are balanced before insertion and right is inserted. 

If your document is balanced and behind the curser is not a right-Terminal, the next character is replaced. If the next character is a \n the editor throws an IllegalArgument exception, as mentioned above, or removes the new line.

What should be:
If the next text right behind the new text position is the right-Terminal, this should be replaced. If not, the terminal should be included without changed.
Comment 3 Benjamin Schwertfeger CLA 2010-07-28 11:06:24 EDT
Created attachment 175416 [details]
Patch for HEAD on 2010-07-28 on o.e.x.ui

Patch for SingleLineTerminalsStrategy to not always overwrite the next character
Comment 4 Sebastian Zarnekow CLA 2010-07-28 15:21:10 EDT
Fixed in HEAD. 

As I did not apply the patch directly, I'ld like you to verify the fix. Thanks.
Comment 5 Benjamin Schwertfeger CLA 2010-07-28 16:29:49 EDT
the current head works also.
Thanks
Comment 6 Karsten Thoms CLA 2017-09-19 17:16:55 EDT
Closing all bugs that were set to RESOLVED before Neon.0
Comment 7 Karsten Thoms CLA 2017-09-19 17:28:15 EDT
Closing all bugs that were set to RESOLVED before Neon.0