atom / language-html

HTML package for Atom
Other
108 stars 142 forks source link

Indention still doesn't work entirely as expected #44

Open gu-stav opened 9 years ago

gu-stav commented 9 years ago

This issue was moved from https://github.com/atom/atom/issues/4379.

Indention got much better in the latest releases, but consider the following HTML-Scenario:

<div>
  <a href="#"
     class="something"
     tal:repeat=""
     tal:condition="">Test</a>
</div>

When I copy the <a/> and paste it (2 empty spaces before), Sublime3 gives me (the expected result):

<div>
  <a href="#"
     class="something"
     tal:repeat=""
     tal:condition="">Test</a>

  <a href="#"
     class="something"
     tal:repeat=""
     tal:condition="">Test</a>
</div>

in Atom (OSX, 0.152) it becomes:

<div>
  <a href="#"
     class="something"
     tal:repeat=""
     tal:condition="">Test</a>
     <a href="#"
     class="something"
     tal:repeat=""
     tal:condition="">Test</a>
</div>

Auto-Indent is turned on for language-html. It's not about the <a/>-Tag - I can reproduce it with every other element aswell.

50Wliu commented 9 years ago

I can still reproduce this under latest master.

muppetjones commented 9 years ago

The indent problem is atom-wide (since 0.192 as far as I can tell): here.

eviljoe commented 8 years ago

I also have problems with indenting HTML that contains tags that have line breaks in their opening tag. For example, have the following HTML:

<div>
    <div class="class1 class2" id="thatBrokenDiv"
        height="100" width="100">
    </div>
</div>

When I highlight it and use the Editor: Auto Indent command, I get the following result:

<div>
    <div class="class1 class2" id="thatBrokenDiv"
    height="100" width="100">
</div>
</div>

The inner div's closing tag is not indented enough. I make a lot of Angular templates which can sometimes involve a LOT of custom attributes specified on the opening tags. To keep my code clean, I wrap the tags at 120 characters. This causes no end of problems when I go to auto-indent my HTML templates.

rodmax commented 8 years ago

I use atom 1.7.4 and have the same with @eviljoe issue when I write tag's attributes in multiple lines. The biggest problem as for me it's when a close tag has no the same indent with the open tag

Maybe someone can explain status regarding this issue

50Wliu commented 8 years ago

Maybe someone can explain status regarding this issue

No one (as far as I know) is actively working on this issue.

revelt commented 6 years ago

To me this happens most often when I move chunks over lines and there are cheeky indentations above. For example:

move_lines_too

dariosalvi78 commented 4 years ago

still happening in 2020. Any workaround?

rodmax commented 4 years ago

@dariosalvi78, in 2020 I highly recommend you to use vs code :)

For me now is no one reason to stay using atom

Regarding the issue, I made fork https://github.com/rodmax/language-html-custom

In which I quickly rewrite parser regexps To satisfy my needs, but it seems, I broke php support and maybe something else

dariosalvi78 commented 4 years ago

yeah, I have tried VS code for a while, indentation works better, but I still prefer Atom for its simple interface TBH. It's a pity something so basic like indentation doesn't work as it should. There's also Atom beautify but it didn't solve my problem.

revelt commented 4 years ago

@rodmax In my humble opinion, VSCode is excels at JS/TS front-end development. But in writing JS programs, specifically, npm packages, Atom is superior, mainly because of stellar Atom plugin work done by steelbrain. For example, VSCode ESLint plugin can't whitelist ESLint rules for autofixing — one can't even use AVA in VSCode because of this. Atom on other hand can whitelist ESLint autofixing. Of course, it's better to switch to node-tap which has the global --only flag to toggle the test isolation feature and solves autofixing issue that way... Atom has its strengths.

rodmax commented 4 years ago

@revelt I assume that the atom has plugins that are better than the vscode counterparts, but i just mean the follow:

And the main point today it is support and community,unfortunately the atom is losing popularity

the formula is simple: the more people around the product the better

@dariosalvi78 you are right, vs-code by default have too many :traffic_light: enabled by default, personally i disabled all them and appearance looks like atom, simple and ascetic