Question

Working with eclipse in a java collapsed file if i try to write a method between two collapsed methods when I write public and press space automatically the ide collapses the word public inside the method below.

State initial 
   - public methodA()
   - public methodC()

Step 1:
   - public methodA()
     public 
   - public methodC()

Eclipse bug
   - public methodA()
   - public methodC() //Error because public is declared twice!

If I write the method faster the problem doesn't occur. Any form to avoid this weird behaviour without disable code folding?

Thanks in advance

Was it helpful?

Solution

What I do is to unfold the method before where I want to insert the code. Then it doesn't actually fold the new text into the previous (folded) method. But the simplest way is probably to just not fold the code and use the outline view to navigate around the file.

OTHER TIPS

You really have only a few things you can do besides disabling folding. Even though the "public" you just typed gets folded into the following method it is still present in the text and the cursor is still just after the last letter. You can:

  • Continue typing and the public will become visible, as will the following method that was previously folded. This will through off the formatting, though.
  • Press Enter. This will move you to the next line and unfold the following method, but it will disentangle the code you're typing from that next method. You're on the next line after the "public" but the formatting stays nice. Just typing a backspace will get the cursor back into the right place and you can continue typing from there.
Licensed under: CC-BY-SA with attribution
Not affiliated with StackOverflow
scroll top