0

I like my workflow to be streamlined and PhpStorm really helps me with this.

When I am creating an array in a php code template I can use shift + + to Complete the Current Statement

$array = [
    'key'**TextCusrorHere** => 'value'
    'anotherkey' => 'anothervalue',
];

When I invoke the Complete the Current Statement command where the text cursor is, the following happens:

$array = [
    'key' => 'value', // note the comma gets added to the end of the line 
    **TextCursorHere**
    'anotherKey' => 'anotherValue',
];

Now my problem is that the same functionality does not occur when editing in a JavaScript file.

For Example:

var object = {
    key**TextCursorHere**: "value"
    anotherKey: "anotherValue",
};

When I invoke the Complete the Current Statement command where the text cursor is, the following happens:

var object = {
    key: "value" // note that the comma DOES NOT get added
    **TextCursorHere**
    anotherKey: "anotherValue",
};

Please note that I am not referring to trailing commas on the last element of an array or last property of an object. I can post my configuration if that helps.

2
  • 1
    How it is a problem? Trailing commas in JS is quite uncommon. Commented Feb 22, 2017 at 9:44
  • @AlexBlex I have updated my post to show that I am not referring to trailing commas but array elements or object properties. For instance I may want to insert an element or object property at the start of an array or object declaration. This would mean it would be nice for the PhpStorm to add the comma. Commented Feb 24, 2017 at 9:57

1 Answer 1

2

This doesn't work currently, please vote for WEB-13348

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.