Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

php-language-features: Add html indent rule #98181

Closed
wants to merge 1 commit into from

Conversation

Abdillah
Copy link

This PR fixes #62077.

Testing the change

  1. Create new file.
  2. Change file type to PHP.
  3. Type in some nested matching html tags without manually indenting the line:

a. Without the change.

<div>
<div>
</div>
</div>

b. With the change.

<div>
    <div>
    </div>
</div>

@msftclas
Copy link

msftclas commented May 19, 2020

CLA assistant check
All CLA requirements met.

@roblourens
Copy link
Member

I think this issue is different than I thought it was, since it starts working as soon as the html extension is activated. @aeschli so the onLanguage:html activationEvent is only triggered when a .html file is opened, even though the html language configuration applies to parts of a php file? Do you think we should add onLanguage:php to the html extension?

@Abdillah
Copy link
Author

Abdillah commented May 21, 2020

Do two extensions allowed to share each other code (like sharing one server)? If we can make sure both HTML and PHP extension server recognize embedded PHP, Javascript, and CSS, that would be ideal IMO. Before that implementation, I think it's a lossless trade to solve smaller issue first.

But I don't think that HTML extension parse PHP language. It should switch to PHP when recognize the syntax, or just give warning.

I am new here might not get the context right

@Abdillah
Copy link
Author

Abdillah commented May 21, 2020

Turns out the PHP already support Javascript and CSS. I am not aware of this just by looking at the code. Is there any HTML ext. activation in PHP language mode somewhere? I understand now, it is in the basic plugin and how everything put together.

I've also tested the onLanguage:php solution too and it works well. Moreover, we can easily provide auto-closing completion (#76800) as well.

@aeschli
Copy link
Contributor

aeschli commented May 26, 2020

PHP defines HTML as an embedded language here: https://github.com/microsoft/vscode/blob/master/extensions/php/package.json#L44. The bug is that VSCode doesn't activate 'html' when it needs it's indent rules. As HTML defines the indent rules in code, activation is necessary.

It's a VSCode issue. I suggest to create a new issue and assign it to @alexdima.

The PR is not good, PHP must not define any html settings, it will cause conflicts. PHP could define a new language php-html, use that for embedding and define rules for that. But I wouldn't do that as it leads to duplication.

@roblourens
Copy link
Member

Oh, I get it. Thanks @aeschli. Filed #98621

@roblourens roblourens closed this May 27, 2020
@github-actions github-actions bot locked and limited conversation to collaborators Jul 11, 2020
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

HTML editing features don't work well in PHP files
4 participants