NuSphere Forums Forum Index
NuSphere Forums
Reply to topic
Smart indent + Auto-close brackets != Smart brackets


Joined: 29 Jan 2008
Posts: 11
Reply with quote
I have a couple annoyances regarding these features and how I'd like it if they worked together... but currently do not.

When I type
Code:

  function doSomething() {

The right bracket is completed and then after I hit enter I get the following
Code:

  function doSomething() {
  }

The cursor has the right bracket stuck to the side of it. Not really stuck but as I type it will always be there to the right until I arrow away from it. If I leave it as is and type another bracketed structure I'll get this:
Code:

  function doSomething() {
    if (TRUE) {
    }}


When I get stuck next to a bracket I correct the issue by hitting return, arrowing up once and hitting tab twice. It is annoying to have to repeat this sequence each and every time I start a new block of code.

What I would like to happen is the following when I write a auto-completed bracket and then hit enter is:
Code:

  function doSomething() {
    | // <- cursor
  }
// or
  function doSomething() {
    if (TRUE) {
      | // <- cursor
    }
  }

Basically to have the smart indent and auto-close bracket features work together to correctly indent me and place the closing bracket indented properly on the line below the cursor when creating a new block of code. I could even live with it happening with parentheses as well since I commonly write large array structures like so:
Code:

$arr = array(
  'cat' => 'meow',
  'dog' => 'woof',
  'complex' => array(
    'foo' => 'bar',
    'bar' => 'foo',
  ),
);


Can this please happen?
View user's profileFind all posts by stackSend private message


Joined: 09 Aug 2007
Posts: 24
Reply with quote
It's easy to make this happen by yourself. Just go to tools->settings->Code Templates. Then, for change function to look how you want it. Here's how mine looks.
Code:

function |() {  //<-The pipe `|` is where the cursor defaults to
        //<-If you put a tab in the Template, it will be there when you use the shortcut.
}
View user's profileFind all posts by tj111Send private message


Joined: 29 Jan 2008
Posts: 11
Reply with quote
I could relearn to hit ctrl-j after typing function but I would still be left with the problem for all other cases where I use brackets. Not to mention all my method definitions would have wonky formatting since the templates line everything up inside themselves not with the line they were fired on.

Code:

  protected function |() {
                   // <- tab is there
            } // <- not lined up with the protected keyword


Lining up within the template is also the reason I couldn't just create a generic bracket template myself.

Out coding standard is to always use brackets even for one line if statements and case statements so to have phpEd do this little bit of extra formatting for me saves me a lot of annoying typing. Not to mention I've rarely used code templates and have to tech myself to use them.

I don't want to go down the path of having to define a private, protected, public, static private, static protected, static public and so on template so I can get just the function declarations to line up.
View user's profileFind all posts by stackSend private message


Joined: 31 Jul 2008
Posts: 17
Location: Basingstoke, UK
Reply with quote
Has there been any update on this? I'm looking to switch from using Zend Studio to PhpED, and this is currently the single most annoying problem that I've found with PhpED. If this can be fixed, I'll have no reservations about using PhpED full-time instead of Zend Studio.
View user's profileFind all posts by Lord d'EathSend private message


Joined: 29 Aug 2007
Posts: 39
Reply with quote
Okay, so then I go and install the latest version and ... hello ... the inserting the cursor on a blank line between brackets is working as desired, although not in every situation.

It's a step in the right direction though.
View user's profileFind all posts by StryksSend private message
Site Admin

Joined: 13 Jul 2003
Posts: 8344
Reply with quote
Quote:
although not in every situation.

I'm not sure what you mean. If you press enter while cursor is in between the braces, it will get indented (unless you have smart-indent feature turned off):
blah{|}

=>

blah{
....|
}

_________________
The PHP IDE team
View user's profileFind all posts by dmitriSend private messageVisit poster's website


Joined: 31 Jul 2008
Posts: 17
Location: Basingstoke, UK
Reply with quote
This has started working better in PhpED 5.5, although with "Cursor beyond EOL" disabled, the blank line in the middle isn't indented. I absolutely hate being able to position the cursor beyond the end of the line (I much prefer to see where characters actually exist), so can't we have PhpED inserting a tab character on that middle line if "Cursor beyond EOL" is disabled, please?

Thanks.
View user's profileFind all posts by Lord d'EathSend private message
Smart indent + Auto-close brackets != Smart brackets
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
All times are GMT - 5 Hours  
Page 1 of 1  

  
  
 Reply to topic