Comments auto-indent behavior - by design, configurable, or a bug?

I'm using PhpStorm 5.04.  When editing PHP or JS, pressing enter within a comment that doesn't start at the beginning of a line, puts the cursor at the beginning of the next line.  Is this is by design, configurable, a bug, or would it be a feature request?  (I looked through the config settings, searched Google, and searched the forums, but didn't see anything.)

Here's visually what I mean.  Editing PHP, let's say things look like this.  The underscore shows where the cursor is.

    protected $foo; // this is the description of_

Pressing enter moves the cursor to next line, indented, but "at the beginning":

    protected $foo; // this is the description of

Using /* */, starting with this:

    protected $foo; /* this is the description of_

Pressing enter:

    protected $foo; /* this is the description of
    * _

In JS, // comments work the same way, but for /* */ comments, the editor doesn't enter the * on the next line and the */ on the line after.

(I can kind of understand the current behavior using // comments, because there's no way to know if the user wants to continue the comment or if the comment is done and the next line will be code.  But I would think that /* */ comments would be aligned in PHP and automatically closed in JS...)


1 comment
Comment actions Permalink

Hi Walter,

I'm not sure myself (only corresponding dev can tell you for sure) but I think it's a feature (and I personally like how it behaves).

I'm not 100% sure what you are trying to do here with such comment, but try this approach: comment before field declaration.

* My field description
protected $foo;

If you want to document what this field/etc does and provide type hint for IDE, use this kind of PHPDoc comment (here I assumed that $foo is a string):

* @var string My field description
protected $foo;

But in any case -- if you think that such behaviour is wrong, feel free to check Issue Tracker for existing tickets and submit new one if none found.


Please sign in to leave a comment.