Fix unclosed property drawers causing a crash #102
Merged
Add this suggestion to a batch that can be applied as a single commit.
This suggestion is invalid because no changes were made to the code.
Suggestions cannot be applied while the pull request is closed.
Suggestions cannot be applied while viewing a subset of changes.
Only one suggestion per line can be applied in a batch.
Add this suggestion to a batch that can be applied as a single commit.
Applying suggestions on deleted lines is not supported.
You must change the existing code in this line in order to create a valid suggestion.
Outdated suggestions cannot be applied.
This suggestion has been applied or marked resolved.
Suggestions cannot be applied from pending reviews.
Suggestions cannot be applied on multi-line comments.
Suggestions cannot be applied while the pull request is queued to merge.
Suggestion cannot be applied right now. Please check back later.
Fixes #98.
@xiaoxinghu When a property drawer is unclosed, this just treats it as text.
I've added the
modify
method forLexer
, which allows you to modify a token in the lexer in-place. So in this case, if we see a property drawer token after trying to parse a property drawer, then we know it is unclosed and can modify it to be text.A probably better approach for the future is to have the lexer check ahead for a drawer close, and only treat
:PROPERTIES:
as adrawer.begin
token if there is a close for the drawer.Edit: actually I think this should technically be handled in the parser (as it is in this PR), because the lexer shouldn't really be able to deal with nesting. It's probably okay to mix and match the lexer and parser a bit though, as long as they work properly.