language-mcfunction icon indicating copy to clipboard operation
language-mcfunction copied to clipboard

greedy_parent rule for say command doesn't apply properly

Open Alluysl opened this issue 4 years ago • 4 comments

Bug report checklist: [✔️] The language-mcfunction extension only provides syntax highlighting. Have you confirmed that your issue is with the syntax highlighting, and not other features such as squiggly underlines, warning indicators, and/or pop-ups? [✔️] Ensure that you are able to reproduce the issue without any other datapack-related extensions enabled. [✔️] Make sure you attach a screenshot to your bug report. Bug reports without a screenshot will be closed.

Bug description: In Sublime (don't know about VSC), the say command which should highlight everything after it in a single color, doesn't do so unless called within an execute command, or preceded by a space (third line is a lone tab): image

Alluysl avatar Jul 30 '21 15:07 Alluysl

I'm able to reproduce this in SublimeText and VSCode, but only with the say command - which, at first, I thought was strange, until I dug into the version-agnostic grammar and made the grim realization that say is effectively special-cased to do this.

The behaviour outlined in this issue is definitely a bug. However, I'm also concerned about other potential bugs caused by greedy_parent as a whole - even if it's fixed and working as intended. For example: somebody has the name say for their storage, objective, or fake-player, in which case the rest of the line will be consumed.

The solution I'm gunning for is to simply remove the greedy_parent rule altogether. A side-effect of this change is that all text after any actual say commands will also go back to being highlighted independently. (On the other hand, selectors after say will be highlighted.) One might argue that this only shifts the problem from one place to another, but I don't have an issue with this solution because it's more in-line with the rest of the version-agnostic grammar. As always, I'll save the special-casing for the version-specific grammars ~~that may or may not ever come to fruition~~.

Arcensoth avatar Jul 30 '21 16:07 Arcensoth

Putting this here so it's easy to copy-paste for reference:

say execute run scoreboard objectives list
 say execute run scoreboard objectives list
	say execute run scoreboard objectives list
	 say execute run scoreboard objectives list
execute run say execute run scoreboard objectives list

Arcensoth avatar Jul 30 '21 16:07 Arcensoth

I don't feel like this is worth opening a separate issue, I noticed that putting kill as the last thing in the file (so [ k ][ i ][ l ][ l ][EOF] - the problem doesn't happen when there's a space or a line break after it) highlights it as a syntax error: image

It's not a problem with execute or with a target: image image

Alluysl avatar Aug 01 '21 16:08 Alluysl

I don't feel like this is worth opening a separate issue, I noticed that putting kill as the last thing in the file (so [ k ][ i ][ l ][ l ][EOF] - the problem doesn't happen when there's a space or a line break after it) highlights it as a syntax error: image

It's not a problem with execute or with a target: image image

I can imagine why that's happening but I think it's better off in a separate issue, so I've created #53 for this.

Arcensoth avatar Aug 23 '21 20:08 Arcensoth