fxbois / web-mode

web template editing mode for emacs
https://web-mode.org
GNU General Public License v3.0
1.63k stars 262 forks source link

Need to constantly use `web-mode-dom-normalize` #1290

Closed kjnez closed 7 months ago

kjnez commented 7 months ago

When I edit HTML files (with django template), I find that I have to use web-mode-dom-normalize every so often. If I don't do that, the following will happen (| denotes the cursor):

<div class="flex">
...
</div|

After hitting ">", it becomes this

<div class="flex">
...
</div>    |

Note the space between ">" and the cursor. If I hit backspace delete, it becomes this

<div class="flex">
...
</div    |

Note that the space still exists. And if I hit ">" again, it becomes this

<div class="flex">
...
</div>    |

Basically, the space will always be there and cannot be deleted. Using web-mode-dom-normalize solves this problem but I doubt this is the desired behavior.

Sometimes there will be the space regardless of whether I'm near the end of the div.

fxbois commented 7 months ago

do you use TAB as indentation char ?

kjnez commented 7 months ago

Yes, my indent-tabs-mode is t.

kjnez commented 7 months ago

Also, I don't know how exactly this unwanted behavior is triggered but one way can be this (| is the cursor):

<div>
...
</div>
<|
<div>
...
</div>

If I hit "d", it becomes

<div>
...
</div>
<d        |
<div>
...
</div>
fxbois commented 7 months ago

web-mode does not handle well indentation with tabs. Do not hesitate to provide a patch for this

kjnez commented 7 months ago

For anyone running into the same problem, this can be partially solved by

(add-hook 'web-mode-hook (lambda () (indent-tabs-mode -1)))