Skip to content
This repository has been archived by the owner on Sep 6, 2021. It is now read-only.

Option to indent PHP code based on the HTML around it #10038

Closed
mpivchev opened this issue Nov 28, 2014 · 14 comments
Closed

Option to indent PHP code based on the HTML around it #10038

mpivchev opened this issue Nov 28, 2014 · 14 comments

Comments

@mpivchev
Copy link

Hello. I have a problem with the PHP code not indenting properly. What happens is every time I type "<?php" all the code after this line does not indent. I tried removing all the plugins , same thing. Here is an example:
mxx2yqi

@mpivchev
Copy link
Author

Anyone ?

@TomMalbran
Copy link
Contributor

That is how it works. The indentation level doesn't depend on the indentation of <?php. It just depends on the indentation of the rest of the php code inside that file.

You can add the preference "startIndent": false and every line is indented with the same indentation as the previous line. But you loose some of the automatic indentation.

@mpivchev
Copy link
Author

Well that's a little stupid, it should indent properly like everything else...

@TomMalbran
Copy link
Contributor

Notice that the html is inside the php code, not the other way around. So is not that stupid how it works. It just doesn't work as you want it to work, and might not even be an issue to other developers.

I don't mix php and html (is not a good practice) and when I need to I mostly need just 1 line. So this doesn't affect me. If you are also creating a function that outputs html. You might want the php code to align, and not have it aligning itself inside the html blocks.

Anyway. Brackets uses CodeMirror to render the editor, and this is an issue with how the smart indentation works in php in CodeMirror, so it will need to be fixed here. You can submit an issue there if you want.

@TomMalbran
Copy link
Contributor

Is there are CodeMirror issue we are tracking here? Or someone needs to create it?

@redmunds
Copy link
Contributor

redmunds commented Dec 3, 2014

@TomMalbran I am not aware of a CM issue on this. I did a quick search but did not find one.

@peterflynn peterflynn changed the title PHP code does not indent Option to indent PHP code based on the HTML around it Mar 17, 2015
@innovaweb-dev
Copy link

Hi all,
I have the same problem, the news about it?

@juliancesar
Copy link

I have the same problem! Any news?

@klarkc
Copy link

klarkc commented Aug 26, 2015

+1

@marcelgerber
Copy link
Contributor

Just submitted the CodeMirror tracking issue codemirror/codemirror5#3488

@marcelgerber
Copy link
Contributor

This will work as described beginning in Release 1.5.
Closing.

@vidukapoor
Copy link

php code writing error.

@mikael1000
Copy link

I have 1.5... and it don't work. This should be fixed!
However you get a little better experience if you do the hack with { and }:

But that's a bad way to have to do this.

@ficristo
Copy link
Collaborator

@mikael1000 Brackets align the code at the same level of <?php: so it's indented.
In general I think it should indent one more time but I don't know enough of php to say it's the right thing to do.
Since I can reproduce the "issue" on the demo page of CodeMirror you should file a bug there.

Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Projects
None yet
Development

No branches or pull requests

13 participants