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

Markdown file indent-style detection and crash #9082

Closed
sicher opened this issue Dec 14, 2023 · 7 comments · Fixed by #9087
Closed

Markdown file indent-style detection and crash #9082

sicher opened this issue Dec 14, 2023 · 7 comments · Fixed by #9087
Labels
C-bug Category: This is a bug

Comments

@sicher
Copy link

sicher commented Dec 14, 2023

Summary

The tab width auto detection seems to bug on some markdown files and cause a crash when trying to probe the indent-style setting.

Reproduction Steps

I tried this:

  1. Create a markdown file test.md with the following content:
# A test file

          TEST
  Here is some text.
  1. hx test.md
  2. type :indent-style

I expected this to happen:

Helix to report the current indent-style setting.

Instead, this happened:

Helix crashes with internal error: entered unreachable code note: run with RUST_BACKTRACE=1 environment variable to display a backtrace

Platform

Windows

Terminal Emulator

Windows Terminal Version: 1.17.11461.0

Installation Method

scoop

Helix Version

helix 23.10 (f6021dd)

@sicher sicher added the C-bug Category: This is a bug label Dec 14, 2023
@TornaxO7
Copy link
Contributor

type :indent-type

I think you mean :indent-style but yeah. I can reproduce this and I'd like to claim this.

@sicher
Copy link
Author

sicher commented Dec 14, 2023

type :indent-type

I think you mean :indent-style but yeah. I can reproduce this and I'd like to claim this.

Oh, yeah... sorry about that... :)

Also, maybe a different issue but I wonder if the indent auto detection is working as expected. I get 10 space indents set in that file.

@TornaxO7
Copy link
Contributor

Also, maybe a different issue but I wonder if the indent auto detection is working as expected. I get 10 space indents set in that file.

Indeed, I just found that out when you posted your answer xD

@pascalkuthe
Copy link
Member

there are two things going on here which I was kind of aware of before:

  • indent style detection for very short files (like this one) doens't work well. Test is indented with 10 spaces and that is what it uses. I think the exact ratios need to be adjusted in our detection heuristic (potentially we need to add some absolute requirements in addition to values, this may be a case where it hits 50%).

  • the check in :indent-style assumes that indent can have at most 8 spaces but 16 is possible (this was adjusted in a semi-recent PR). The check should just be removed (and the _=> unreachable branches removed)

@TornaxO7
Copy link
Contributor

@pascalkuthe so may I ask what you suggest for a PR for this? Should the PR just remove the unreachable branch?

@pascalkuthe
Copy link
Member

yeah mostly just remove the unreachable branch altough fixing the ident heuristic would be a nice bonus

@TornaxO7
Copy link
Contributor

aye aye captain

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.

3 participants