Repository navigation
syntax: yaml: only treat word: as a key when followed by whitespace - #4293
Open
thelastbackspace wants to merge 1 commit into
Open
thelastbackspace wants to merge 1 commit into
thelastbackspace wants to merge 1 commit into
Conversation
A colon only starts a mapping value when it is followed by whitespace or the end of the line, so `- http:example.com` and `url: http://x.com:80` are plain scalars. Also highlight the `-` of a sequence item whose value is a quoted string; the string region ate the space the rule needed. Fixes micro-editor#4286
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment
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 #4286
The YAML rules highlighted any
word:as a key and every:as a mapping colon, so plain scalars like- http:example.comorurl: http://x.com:80/agot key colouring halfway through the value. In YAML a colon only starts a value when it's followed by whitespace or the end of the line, so both rules now require that.The second thing in the screenshot:
- 'http:example.com'left the-uncoloured. The quoted string region starts with(^| )', so it takes the space after the dash, and the sequence rule^[[:space:]]*-no longer matched. It now accepts-followed by a space or the end of the text before the region.I checked it by dumping the highlight groups for a few lines before and after with a throwaway program on top of
pkg/highlight:key: value,key:at end of line,key: |,key: >, tab after the colon,-x: 1and- -xcome out the same as before.