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

Font-lock block literal spilling out #60

Open
dogwynn opened this issue Feb 27, 2018 · 3 comments
Open

Font-lock block literal spilling out #60

dogwynn opened this issue Feb 27, 2018 · 3 comments

Comments

@dogwynn
Copy link

dogwynn commented Feb 27, 2018

Problem

When leaving a block literal to continue a dictionary definition, the rest of the dictionary is font-locked as a string.

screen shot 2018-02-27 at 3 49 01 pm

This implies that the rest of the dictionary is part of the string literal, which is not true.

In [5]: yaml.load('''
   ...: - text: >-
   ...:     This is a block literal with font-lock spilling out
   ...:   a: 1 
   ...:   b: 2 
   ...:   c: {} 
   ...: ''')
Out[5]: 
[{'a': 1,
  'b': 2,
  'c': {},
  'text': 'This is a block literal with font-lock spilling out'}]

This is new behavior.

Current Solutions

The addition of comment symbols seems to "fix" the issue.

screen shot 2018-02-27 at 3 57 39 pm

However, when the comment symbol is deleted, the font-lock spills back in:

screen shot 2018-02-27 at 4 06 57 pm

dogwynn added a commit to dogwynn/yaml-mode that referenced this issue Feb 28, 2018
Modifies `yaml-font-lock-block-literals` to initialize `min-level` to
`((current-indentation) - yaml-indent-offset)`
@dogwynn dogwynn mentioned this issue Feb 28, 2018
@dogwynn
Copy link
Author

dogwynn commented Feb 28, 2018

v0.0.11 v0.0.13 does not have this problem.

@wasamasa
Copy link
Collaborator

Well this is funny. The block literal code existed for quite some time in the font locking rules, but wasn't applied properly, so I fixed that in my recent commits. Apparently this reveals that its logic isn't perfect. Your PR attacks the right place, but you'd need to understand the existing logic to make progress on this problem.

@dogwynn
Copy link
Author

dogwynn commented Feb 28, 2018

Yeah, I spent a bit of time last night dowsing the variable space to try to wrap my brain around the logic to no avail. I hate that this isn't working. I'm using YAML to persist my exams and quizzes, so I make extensive use of block literals.

For the time being, I've reverted to v0.0.11 v0.0.13 until I can get some time to grok the font-locking code.

Thanks for the module all the same!

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

2 participants