#320 Smarter typing of closed curly braces

Editor (234)
Dirk Bergstrom

When a closed curly brace preceded by a space is added
by smart typing, it should be placed on the next line,
properly indented. The cursor should remain where it
is. Like this:

Before typing open brace (cursor at 'I'):
if (blah) I

After typing open brace:
if (blah) {I

With the current system, I have to hit return twice,
then go up one line.

When a brace is immediately preceded by a character
(like a variable name), the closing brace should not be
put on the next line.


  • Jan Ploski
    Jan Ploski

    Logged In: YES

    Correct autocompletion of closing curly braces is more complicated than what you suggest. We should
    basically reproduce the behaviour of JDT's Java editor. When you type an opening brace, no autocompletion
    happens at first - after all, maybe you want to close this block on the same line. However, if you press
    return immediately after the opening brace, a correctly indented closing brace is inserted, UNLESS the block
    is already terminated by an existing closing brace. In other words, we would have to count/match braces in
    the remaining source to determine whether a closing brace should be inserted or not. Tricky.