Some Eclipse Foundation services are deprecated, or will be soon. Please ensure you've read this important communication.
Bug 540819 - Unexpected behaviour of editor when trying to type { inside a string literal
Summary: Unexpected behaviour of editor when trying to type { inside a string literal
Status: CLOSED DUPLICATE of bug 520081
Alias: None
Product: JDT
Classification: Eclipse Project
Component: Text (show other bugs)
Version: 4.9   Edit
Hardware: PC Windows 10
: P3 normal (vote)
Target Milestone: ---   Edit
Assignee: JDT-Text-Inbox CLA
QA Contact:
URL:
Whiteboard:
Keywords:
Depends on:
Blocks:
 
Reported: 2018-11-06 04:21 EST by Mauro Molinari CLA
Modified: 2018-11-06 05:40 EST (History)
1 user (show)

See Also:


Attachments

Note You need to log in before you can comment on or make changes to this bug.
Description Mauro Molinari CLA 2018-11-06 04:21:20 EST
Consider the following code:

package test;

public class Test {
  void foo() {
	  throw new IllegalStateException("aaa |" );
  }
}

Assume "|" is the cursor position. Try to type: { (open curly brace)

Expected behaviour:

throw new IllegalStateException("aaa {");

Actual behaviour:

throw new IllegalStateException("aaa ") {;

Indeed, it seems like the editor tries to propose some sort of "create new anonymous inner class" proposal, but it's very annoying that this is triggered when I'm typing inside a string literal, because it's indeed an undesired behaviour.

By trial and error I discovered that if you hit backspace immediately, the "{" is put back into the string literal, but when this happens you usually have a "WTF" moment and hitting backspace immediately after the "{" is not the first thing that comes into your mind, especially because you meanwhile may have written something else after the "{", and then pressing backspace repeatedly is useless to recover: you'll end up deleting the undesired output and trying again to put it inside the string literal, in an endless loop... It's a bit frustrating ;-)
Comment 1 Stephan Herrmann CLA 2018-11-06 05:26:39 EST

*** This bug has been marked as a duplicate of bug 520081 ***