Summary
Pressing Enter inside short array syntax [] does not indent the new line. Array elements are only indented when using the legacy array() form, which has a matching curly-brace pattern in indents.scm.
Steps to reproduce
- Open a
.php file.
- Type
$foo->bar([ or array( and press Enter.
Actual behavior
$foo->bar([
new line starts at column 0
]);
$foo = array(
new line starts at column 0
);
Expected behavior
$foo->bar([
new line indented one level
]);
$foo = array(
new line indented one level
);
Environment
Zed: v1.13.1
OS: Ubuntu 24.04
PHP extension: v0.5.1
Reproduced on a fresh Zed profile (isolated HOME) with only the PHP extension installed and no custom settings, so this is not caused by other extensions or user configuration. if, foreach, and try blocks all indent correctly in the same environment - only short array syntax fails.
Suggested fix
languages/php/indents.scm currently only matches curly-brace nodes. Adding:
(array_creation_expression "]" @end) @indent
(array_creation_expression ")" @end) @indent
resolves it. I've tested this locally against the installed extension and it produces the expected indentation.
Edit: added PR to fix it: #139
Summary
Pressing Enter inside short array syntax
[]does not indent the new line. Array elements are only indented when using the legacyarray()form, which has a matching curly-brace pattern inindents.scm.Steps to reproduce
.phpfile.$foo->bar([orarray(and press Enter.Actual behavior
Expected behavior
Environment
Zed: v1.13.1
OS: Ubuntu 24.04
PHP extension: v0.5.1
Reproduced on a fresh Zed profile (isolated
HOME) with only the PHP extension installed and no custom settings, so this is not caused by other extensions or user configuration.if,foreach, andtryblocks all indent correctly in the same environment - only short array syntax fails.Suggested fix
languages/php/indents.scmcurrently only matches curly-brace nodes. Adding:resolves it. I've tested this locally against the installed extension and it produces the expected indentation.
Edit: added PR to fix it: #139