php-mode icon indicating copy to clipboard operation
php-mode copied to clipboard

Indentation inside of anonymous functions deletes code

Open alanpearce opened this issue 12 years ago • 4 comments

When indent-tabs-mode is enabled and a tab-width of 4, trying to indent a statement inside an anonymous function deletes some characters.

foo(function ($bar) {
    test('baz');
});

With the cursor before test, pressing tab changes the line to

foo(function ($bar) {
t('baz');
});

The number of characters deleted seems to depend on the value of tab-width. With the brace on a newline, the problem doesn't occur

foo(function ($bar)
{
    test('baz');
});

php-mode-coding-style is pear, but not set in my configuration, so it's just using the default. Running php-enable-pear-coding-style manually, then enabling indent-tabs-mode again seems to fix the issue in the buffer.

alanpearce avatar Oct 07 '13 11:10 alanpearce

Deleting code, eessh... Thank you for the detailed bug report. I'm still out of town until tomorrow, but Wednesday I'll be devoting a block of time to working on this on some other recent PHP Mode issues. Sorry about the delay.

ejmr avatar Oct 07 '13 17:10 ejmr

I don't think that it's that bad. My guess is that when no coding style is set, the default pear style isn't initialised properly. Fortunately I discovered that the WordPress style is closer to what I prefer, so I've set that now and my code continues to exist.

alanpearce avatar Oct 07 '13 19:10 alanpearce

I confirm this bug. Is there a work around?

fredericmora avatar Oct 21 '13 20:10 fredericmora

A temporary work around is to either use a different style besides pear via C-c . or manually enable the pear style if you want to use it.

ejmr avatar Oct 21 '13 21:10 ejmr