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

Hang when displaying yaml with comment at start of line #425

Closed
tomgoren opened this issue Nov 21, 2018 · 3 comments
Closed

Hang when displaying yaml with comment at start of line #425

tomgoren opened this issue Nov 21, 2018 · 3 comments

Comments

@tomgoren
Copy link

tomgoren commented Nov 21, 2018

When using bat on YAML files that include comments which start at the beginning of a line, that is, the first character of the line is a #, bat will hang indefinitely, and never finish displaying the file.

Contents of working file via cat:

$ cat works.yml
test: value

still: okay

 # comment with hash character at beginning of line, but with a space first

will: reach here

Contents of working file via bat:

$ bat works.yml
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: works.yml
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ test: value
   2   │
   3   │ still: okay
   4   │
   5   │  # comment with hash character at beginning of line, but with a space first
   6   │
   7   │ will: reach here
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
$

Without the leading space in the comment line

Contents of broken file via cat:

$ cat broken.yml
test: value

still: okay

# comment with hash character at beginning of line

will: not reach here

Contents of working file via bat:

$ bat broken.yml
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: broken.yml
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ test: value
   2   │
   3   │ still: okay
   4   │

From this point on, it will linger forever and never finish. Even the comment line isn't shown. Something seems to be wrong with the syntax parsing in this case.

It does work with the -A flag enabled:

$ bat -A broken.yml
───────┬────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
       │ File: broken.yml
───────┼────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
   1   │ test:•value␊
   2   │ ␊
   3   │ still:•okay␊
   4   │ ␊
   5   │ #•comment•with•hash•character•at•beginning•of•line␊
   6   │ ␊
   7   │ will:•not•reach•here␊
───────┴────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────────
$

It is consistently repeatable. Different values of --style do not change the outcome, it hangs every time.

$ bat --version
bat 0.9.0

bat installed via Homebrew on OS X Mojave.

Darwin Kernel Version 18.2.0: Fri Oct  5 19:41:49 PDT 2018; root:xnu-4903.221.2~2/RELEASE_X86_64 x86_64
@keith-hall
Copy link
Collaborator

there was a similar issue which was fixed upstream: trishume/syntect#219
I wonder what is happening in this case

@sharkdp
Copy link
Owner

sharkdp commented Nov 21, 2018

@tomgoren Thank you for the detailed bug report!

I can not reproduce this.

This looks very much like the bug that I have reported upstream, as @keith-hall mentioned. It only appeared if a syntax set was dumped to disk and reloaded again.

Did you use bat cache --init in the past (with an older version of bat)? Can you try to run

bat cache --clear

to see if the error goes away?

If that is the case, you should be able to run bat cache --init again without any issues.

@tomgoren
Copy link
Author

Holy moly @sharkdp - that fixed it! Thanks. Sorry for any confusion.

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

No branches or pull requests

3 participants