micro-editor / micro-editor/micro
Runtime error on syntax file when bad pattern
Nobody has claimed this yet.
- Dominant language
- Go
- Stars
- 29.6k
- Forks
- 1.4k
- Avg merge
- 2d 18h
- Merged PRs (30d)
- 10
Description
Description of the problem or steps to reproduce
1 filetype: nfo
2
3 detect:
4 filename: "^(nfo|gnu|bsd|nix|unx|osx|win|[aso])\\.|\\.(nfo|list)$)"
5
6 rules:
7 - type:
8 start: "(^|\\s)##"
9 end: "$"
10 rules: []
11 - comment:
12 start: "(^|\\s)#[^#]?"
13 end: "$"
14 rules: []
15 - constant.string:
16 start: ">\\s"
17 end: "$"
18 rules: []
If i misslead the pattern by forgetting an ")" at end, i get a runtime panic, and it wont start.
This should be fix by caught the regex compiler and throwing a syntax error message to explain and make easy debuging.
Micro encountered an error: runtime error: invalid memory address or nil pointer dereference
runtime.errorString runtime error: invalid memory address or nil pointer dereference
runtime/panic.go:212 (0x5600a028f77e)
runtime/panic.go:211 (0x5600a028f5cd)
github.com/zyedidia/micro/v2/internal/buffer/buffer.go:615 (0x5600a07682fe)
github.com/zyedidia/micro/v2/internal/buffer/buffer.go:332 (0x5600a0764529)
github.com/zyedidia/micro/v2/internal/buffer/buffer.go:227 (0x5600a0763aff)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:190 (0x5600a07d777d)
github.com/zyedidia/micro/v2/cmd/micro/micro.go:299 (0x5600a07d8643)
runtime/proc.go:203 (0x5600a027b6d2)
runtime/asm_amd64.s:1373 (0x5600a02a9a81)
It should prompt the same as bellow (when missed backslash on a \s)
Error parsing syntax file perl: yaml: line 5: found unknown escape character
Press enter to continue
Specifications
Version: 2.0.6
Commit hash: 60846f54
Compiled on July 16, 2020
OS: Archlinux and Gentoo
Terminal: xfce4-terminal
Contributor guide
No contributing guide indexed for this repository
First steps
- Read the whole issue, then the project's contributing guide.
- Comment on the issue to say you are picking it up — it saves two people doing the same work.
- Fork the repository and make your change on a branch.
- Open a pull request that references the issue number.
Research direction
Start at internal/buffer/buffer.go around lines 615, 332, and 227, then follow the syntax-file loading path from cmd/micro/micro.go. Reproduce the malformed regex in the issue and compare it with the existing YAML escape error behavior. Done means a bad pattern reports a syntax error and prompt instead of causing a nil-pointer panic.
Written by the indexing model from the issue text.
Assessment
- Tech stack
- go
- Domain
- cli
- Issue type
- Bug
- Difficulty
- 3/5
- Estimated time
- 1-2 days
- Activity status
- Stale
- Clarity
- Clearly specified
- Newbie friendliness
- 48/100