SpyglassMC / Spyglass

Development tools for vanilla Minecraft: Java Edition data pack developers.
https://spyglassmc.com
MIT License
273 stars 29 forks source link

Record completer does not always complete empty values #1244

Open misode opened 4 weeks ago

misode commented 4 weeks ago

How to reproduce

  1. Type give @s[gamemode= ] in a mcfunction file
  2. Notice that you get completions when the cursor is right in front of the ]
  3. :x: Notice that you don't get completions when the cursor is right after the =

Note: this isn't very common in selector arguments, but it is extremely common in JSON objects

{
  "type": 
}

Cause

When record nodes with an empty value (like the above) are parsed, there is a gap between the end of sep and the start of value. Essentially the value node is an node with an empty range, and the very end of the record. This prevents the record completer from calling value.

misode commented 4 weeks ago

I modified the record completer a bit in #1238 so it works for JSON completions, but the issue with selector arguments still remain. This is caused by a dispatch trying to find the ctx.offset inside the value node, which won't match. This should be looked into in the future