Block comments get misaligned on copy+paste

PhpStorm has recently started to mess code comments when I copy and paste, and "Reformat Code" doesn't seem to fix it. I haven't changed any code style setting and, if I had, I've no idea which one controls this. Any idea?

        /*
* Block comments like this get sent to first line
 */
      $foo = $this->getFoo($fooId);

 

0
5 comments

Hello Alvaro,

Do you have anything in Settings | Editor | Code Style > in the Formatter tab on the right under the Do not format line?

0

No, it's empty.

Interestingly, reformat code seems to work for docblocks (/**), but not for regular comments (/*). I've tried setting PHP code style from PER-CS (previously I was using PSR1/PSR-2) but it doesn't make any difference.

 I can't tell for sure if copying and pasting is still broken.

0

Will it be possible to share your Code Style settings? They can be exported in Settings | Editor | Code Style > click on the gear icon near the scheme name > Export > IntelliJ IDEA code style XML.

0

Here you are.

<code_scheme name="Project" version="173">
  <option name="LINE_SEPARATOR" value="&#10;" />
  <PHPCodeStyleSettings>
    <option name="COMMA_AFTER_LAST_ARRAY_ELEMENT" value="true" />
    <option name="COMMA_AFTER_LAST_PARAMETER" value="true" />
    <option name="COMMA_AFTER_LAST_CLOSURE_USE_VAR" value="true" />
    <option name="COMMA_AFTER_LAST_ARGUMENT" value="true" />
    <option name="COMMA_AFTER_LAST_MATCH_ARM" value="true" />
    <option name="PHPDOC_BLANK_LINE_BEFORE_TAGS" value="true" />
    <option name="PHPDOC_WRAP_LONG_LINES" value="true" />
    <option name="BLANK_LINES_BETWEEN_IMPORTS" value="1" />
    <option name="LOWER_CASE_BOOLEAN_CONST" value="true" />
    <option name="LOWER_CASE_NULL_CONST" value="true" />
    <option name="ELSE_IF_STYLE" value="COMBINE" />
    <option name="KEEP_RPAREN_AND_LBRACE_ON_ONE_LINE" value="true" />
    <option name="BLANK_LINES_AFTER_OPENING_TAG" value="1" />
    <option name="KEEP_BLANK_LINES_AFTER_LBRACE" value="0" />
    <option name="FORCE_SHORT_DECLARATION_ARRAY_STYLE" value="true" />
    <option name="NEW_LINE_AFTER_PHP_OPENING_TAG" value="true" />
    <option name="FORCE_EMPTY_METHODS_IN_ONE_LINE" value="true" />
    <option name="FORCE_EMPTY_CLASSES_IN_ONE_LINE" value="true" />
    <option name="MULTILINE_CHAINED_CALLS_FIRST_CALL_ON_NEW_LINE" value="true" />
    <option name="MULTILINE_CLOSURE_LAMBDA_ON_NEW_LINE" value="true" />
    <option name="HEREDOC_ON_SAME_LINE" value="true" />
    <option name="ATTRIBUTES_WRAP" value="2" />
  </PHPCodeStyleSettings>
  <codeStyleSettings language="JSON">
    <indentOptions>
      <option name="INDENT_SIZE" value="4" />
      <option name="CONTINUATION_INDENT_SIZE" value="4" />
    </indentOptions>
  </codeStyleSettings>
  <codeStyleSettings language="PHP">
    <option name="KEEP_BLANK_LINES_BEFORE_RBRACE" value="0" />
    <option name="BLANK_LINES_AFTER_PACKAGE" value="1" />
    <option name="ALIGN_MULTILINE_PARAMETERS" value="false" />
    <option name="ALIGN_MULTILINE_EXTENDS_LIST" value="true" />
    <option name="CALL_PARAMETERS_WRAP" value="5" />
    <option name="CALL_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
    <option name="CALL_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
    <option name="METHOD_PARAMETERS_WRAP" value="5" />
    <option name="METHOD_PARAMETERS_LPAREN_ON_NEXT_LINE" value="true" />
    <option name="METHOD_PARAMETERS_RPAREN_ON_NEXT_LINE" value="true" />
    <option name="EXTENDS_LIST_WRAP" value="5" />
    <option name="FOR_STATEMENT_LPAREN_ON_NEXT_LINE" value="true" />
    <option name="FOR_STATEMENT_RPAREN_ON_NEXT_LINE" value="true" />
    <option name="ARRAY_INITIALIZER_WRAP" value="5" />
    <option name="ARRAY_INITIALIZER_LBRACE_ON_NEXT_LINE" value="true" />
    <option name="ARRAY_INITIALIZER_RBRACE_ON_NEXT_LINE" value="true" />
    <option name="IF_BRACE_FORCE" value="3" />
    <option name="DOWHILE_BRACE_FORCE" value="3" />
    <option name="WHILE_BRACE_FORCE" value="3" />
    <option name="FOR_BRACE_FORCE" value="3" />
  </codeStyleSettings>
  <codeStyleSettings language="Shell Script">
    <indentOptions>
      <option name="INDENT_SIZE" value="4" />
      <option name="TAB_SIZE" value="4" />
    </indentOptions>
  </codeStyleSettings>
</code_scheme>
0

Thank you. Unfortunately, I see nothing special here.

I reproduced the issue and can confirm that when pasting the comment right from the beginning of the line, the block comment is pasted as expected. However, if the line already has some indentation, the block will look as in your example.

I found a similar though quite old report on YouTrack: https://youtrack.jetbrains.com/issue/WI-26904. Please vote for it to be aware of the updates.

1

Please sign in to leave a comment.