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

When editing HTML automatically inserted tabs are broken. #2236

Closed
nilq opened this issue Apr 23, 2022 · 13 comments · Fixed by #5918
Closed

When editing HTML automatically inserted tabs are broken. #2236

nilq opened this issue Apr 23, 2022 · 13 comments · Fixed by #5918
Labels
C-bug Category: This is a bug

Comments

@nilq
Copy link

nilq commented Apr 23, 2022

Summary

I have set the editor to adapt indentation, when adding new lines. Whenever I edit HTML, the amount of indents grow exponentially.

Reproduction Steps

I am using default settings, on an M1 Mac. This happens every time I edit HTML files.

Helix log

~/.cache/helix/helix.log
2022-04-23T10:10:19.719 helix_view::theme [WARN] Theme: malformed hexcode: foreground
2022-04-23T10:10:19.720 helix_view::theme [WARN] Theme: invalid style attribute: Modifiers
2022-04-23T10:10:19.720 helix_view::theme [WARN] Theme: malformed hexcode: pink
2022-04-23T12:39:03.949 helix_lsp::transport [ERROR] err <- "2022-04-23 12:39:03,948 CEST - WARNING - pylsp.config.config - Failed to load pylsp entry point 'autopep8': No module named 'pycodestyle'\n"
2022-04-23T12:39:03.953 helix_lsp::transport [ERROR] err <- "2022-04-23 12:39:03,953 CEST - WARNING - pylsp.config.config - Failed to load pylsp entry point 'mccabe': No module named 'mccabe'\n"
2022-04-23T12:39:03.954 helix_lsp::transport [ERROR] err <- "2022-04-23 12:39:03,954 CEST - WARNING - pylsp.config.config - Failed to load pylsp entry point 'pycodestyle': No module named 'pycodestyle'\n"
2022-04-23T12:39:03.954 helix_lsp::transport [ERROR] err <- "2022-04-23 12:39:03,954 CEST - WARNING - pylsp.config.config - Failed to load pylsp entry point 'pydocstyle': No module named 'pydocstyle'\n"
2022-04-23T12:39:03.955 helix_lsp::transport [ERROR] err <- "2022-04-23 12:39:03,955 CEST - WARNING - pylsp.config.config - Failed to load pylsp entry point 'pyflakes': No module named 'pyflakes'\n"
2022-04-23T12:39:03.955 helix_lsp::transport [ERROR] err <- "2022-04-23 12:39:03,955 CEST - WARNING - pylsp.config.config - Failed to load pylsp entry point 'pylint': No module named 'pylint'\n"
2022-04-23T12:39:03.956 helix_lsp::transport [ERROR] err <- "2022-04-23 12:39:03,956 CEST - WARNING - pylsp.config.config - Failed to load pylsp entry point 'rope_completion': No module named 'rope'\n"
2022-04-23T12:39:03.956 helix_lsp::transport [ERROR] err <- "2022-04-23 12:39:03,956 CEST - WARNING - pylsp.config.config - Failed to load pylsp entry point 'rope_rename': No module named 'rope'\n"
2022-04-23T12:39:03.956 helix_lsp::transport [ERROR] err <- "2022-04-23 12:39:03,956 CEST - WARNING - pylsp.config.config - Failed to load pylsp entry point 'yapf': No module named 'yapf'\n"
2022-04-23T13:00:24.987 helix_view::editor [ERROR] Failed to initialize the LSP for `text.html.basic` { LSP not defined }

Platform

Mac

Terminal Emulator

Warp, iTerm2

Helix Version

helix 22.03 (d4e45fd)

@nilq nilq added the C-bug Category: This is a bug label Apr 23, 2022
@nilq
Copy link
Author

nilq commented Apr 23, 2022

I tried inserting the following code into a script element directly from the OS clipboard:

var wavesurfer = WaveSurfer.create({
    container: document.querySelector('#waveform'),
    waveColor: '#A8DBA8',
    progressColor: '#3B8686',
    backend: 'MediaElement',
    plugins: [
        WaveSurfer.regions.create({
            regionsMinLength: 2,
            regions: [
                {
                    start: 1,
                    end: 3,
                    loop: false,
                    color: 'hsla(400, 100%, 30%, 0.5)'
                }, {
                    start: 5,
                    end: 7,
                    loop: false,
                    color: 'hsla(200, 50%, 70%, 0.4)',
                    minLength: 1,
                    maxLength: 5,
                }
            ],
            dragSelection: {
                slop: 5
            }
        })
    ]
});

This resulted in a freeze, after the cursor had moved to a column number around ~1500000.

@the-mikedavis
Copy link
Member

For the pasting part, you must paste with space-p instead of Cmd-v: #1021 (comment)

@nilq
Copy link
Author

nilq commented Apr 23, 2022

Then Cmd-v breaks the editor when pasting snippets like the one above. When I press enter, it still adds a weird amount of indentation, and keeps increasing this amount for each repetition.

@the-mikedavis
Copy link
Member

Then Cmd-v breaks the editor when pasting snippets like the one above

Yes. This is a known issue. I'll make a tracking issue for it.

When I press enter, it still adds a weird amount of indentation, and keeps increasing this amount for each repetition.

This is outside of pasting - just with regular editing, right? The indentation mechanism was fully reworked after the 22.03 release. You can try it out by building from source, awaiting nightly releases (#358), or awaiting the next release (May, https://github.com/helix-editor/helix/wiki/FAQ#when-will-the-next-release-be)

@nilq
Copy link
Author

nilq commented Apr 23, 2022

This is general problem outside of pasting as well - though I only experience this behavior when handling HTML, - in Python files things are fine. Will try to upgrade to a new version of Helix, thank you.

@ff2400t
Copy link

ff2400t commented Apr 24, 2022

this is because there is no indent.scm file for html yet

@adsick
Copy link

adsick commented Apr 26, 2022

not sure if it the same thing, but I have this:
image
code taken from https://www.getzola.org/documentation/getting-started/overview/
note: I did :fmt command a few times

@CptPotato
Copy link
Contributor

CptPotato commented May 11, 2022

I'm experiencing similar issues with other languages, too, like markdown.


@adsick this looks like you pasted through the terminal (which treats the input as if the user typed each character), right?
If that's the case, use space p / space P to paste it correctly within helix.

@adsick
Copy link

adsick commented May 13, 2022

@CptPotato thanks, didn't know that. But still :fmt should do it's job regardless.

@the-mikedavis
Copy link
Member

:format (:fmt) calls out to the language server for formatting, so it will only work if you have the HTML language server installed

@soxfox42
Copy link

soxfox42 commented Aug 16, 2022

I've encountered this same issue but when editing a Markdown document, so I don't think it's HTML specific.

In this image, everything was entered manually, and the only time I pressed Tab was for the first indented line. After that, successive lines had exponentially more indentation.
tabs

I think I've worked out the cause, though I haven't looked through the code. Helix seems to calculate the current line's indentation level with a fixed number of spaces. In HTML and Markdown, it appears to be 2 spaces, but I also reproduced the behaviour in Kotlin, where it seems to be 4 spaces. It then indents the new line by that amount, but using the correct indent-style setting. So if indent-style is any value other than the one Helix assumed while looking at the current line, the indentation changes.

Quick diagram:
indent

@jlebon
Copy link
Contributor

jlebon commented Jan 7, 2023

Is there a way to disable automatic indentation for HTML until this is fixed?

@manokara
Copy link

manokara commented Jan 12, 2023

Helix seems to calculate the current line's indentation level with a fixed number of spaces. In HTML and Markdown, it appears to be 2 spaces,

That seems to be true somehow, as the exponential line growth doesn't happen with indent-style 2. Anything higher than 2 does it. It doesn't happen with indent-style t. I've seen this also happen in Vue SFC files, which I believe reuses the HTML logic, making the indentation problem affect the script and style sections as well.

Is there a way to disable automatic indentation for HTML until this is fixed?

I'm afraid not. Per-language editor settings seem to be quite limited at the moment (you can only set indent-style and editor.auto-pairs?), so the only workaround would be to use 2 spaces or hard tabs in your html files.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
C-bug Category: This is a bug
Projects
None yet
Development

Successfully merging a pull request may close this issue.

8 participants