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

Syntax file causes crash when block highlight is missing "rules" block #3536

Closed
helpimnotdrowning opened this issue Nov 12, 2024 · 2 comments

Comments

@helpimnotdrowning
Copy link

Description of the problem or steps to reproduce

In writing a hyperscript extension to the included syntax/html.yaml file, I added these lines:

    - default:
        start: "<script.*?type=\"text/hyperscript\"?>"
        end: "</script.*?>"
        limit-group: symbol.tag
        rules:
        - include: "_hyperscript"

, along with a file named _hyperscript.yaml right next to it:

filetype: _hyperscript

detect:
    filename: "\\._hs$"

rules:
- comment:
        start: "--"
        end: "$"
        #rules:
        #    - todo: "(TODO|XXX|FIXME)"

On starting Micro, opening any html file (or reloading the syntax in an existing window, ie by Ctrl+S) crashes:

Micro encountered an error: runtime.errorString runtime error: invalid memory address or nil pointer dereference
runtime/panic.go:261 (0x452fd8)
runtime/panic.go:260 (0x452fa6)
github.com/zyedidia/micro/v2/pkg/highlight/parser.go:276 (0x85c4e3)
github.com/zyedidia/micro/v2/pkg/highlight/parser.go:266 (0x85bffb)
github.com/zyedidia/micro/v2/pkg/highlight/parser.go:252 (0x8670d7)
github.com/zyedidia/micro/v2/internal/buffer/buffer.go:807 (0x8670b4)
github.com/zyedidia/micro/v2/internal/buffer/buffer.go:392 (0x864485)
github.com/zyedidia/micro/v2/internal/buffer/buffer.go:261 (0x862fc5)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:203 (0x8f3e76)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:331 (0x8f4793)
runtime/internal/atomic/types.go:194 (0x43e99b)
runtime/asm_amd64.s:1650 (0x46fd01)

Uncommenting the "rules" section stops Micro from crashing.

Micro should load this perfectly fine, despite just being a verbose version of --.*$, or should properly complain of a malformed file.

Specifications

  • Ubuntu 20.04.6 LTS
    • micro: 2.0.13/68d88b57 via snap
    • term: SSH --> Debian
  • Debian 12.7 / KDE 5
    • micro: 2.0.11/<no hash in output> via apt/bookworm
    • term: Konsole/pwsh
@helpimnotdrowning helpimnotdrowning changed the title Syntax file fails to load (or crash) when block highlight is missing "rules" block Syntax file causes crash when block highlight is missing "rules" block Nov 12, 2024
@Andriamanitra
Copy link
Contributor

Andriamanitra commented Nov 12, 2024

This should be fixed on master (#3458), although there has not been a release yet since. You may build micro from source or download the nightly release to get the fix.

@JoeKar
Copy link
Collaborator

JoeKar commented Nov 19, 2024

More precisely it was fixed with #3213, which is included in v2.0.14.
Afterwards micro doesn't crash, but you will face the situation #3458 addresses.

@JoeKar JoeKar closed this as completed Nov 19, 2024
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