SublimeText / PackageDev

Tools to ease the creation of snippets, syntax definitions, etc. for Sublime Text.
MIT License
436 stars 83 forks source link

Completion of float values in settings is broken #147

Closed deathaxe closed 7 years ago

deathaxe commented 7 years ago

Something broke the float value completions. The algorithm to detect the prefix 1. does no longer work which results in wrong completions being added and the completion panel not being displayed automatically.

Steps to reproduce

  1. Enter the following key "dpi_scale": 1.
  2. Completion overlay suggesting 1.25 1.5 ... is not displayed automatically
  3. Completing the value with ctrl+space results in something like "dpi_scale": 1.1.25
deathaxe commented 7 years ago

Hmm. I guess you've split the JSON syntax in too little meta.parts with all that meta.expect- ... stuff. Therefore the region_math does no longer work.

Everything between a : and the , was expected to be something like meta.mapping.value. Now there are three parts. meta.expect-..., the meta.setting-value... and the punctuation.separator afterwards.

For good completions there should be only two meta scopes per line

{
    "dpi_scale": 1.0,
    ^^^^^^^^^^^^ meta.mapping.key
                ^^^^^ meta.mapping.value
}

By including the : into meta.mapping.key and , into meta.mapping.value one could place the cursor just in front of those separators and would still get the correct meta.scope. Now you don't and you'll need to guess where you are.

deathaxe commented 7 years ago

Values with space between value and , are not handled at all.

screenshot

FichteFoll commented 7 years ago

: is not part of the key and , is not part of the value. We should not modify the general definition of these meta scopes, which haven't been standardized yet but should be imho, and instead look into finding a way for our unique situation. See #149.

deathaxe commented 7 years ago

This situation is indeed not unique. When handling completions I had to struggle with the scope boundaries several times already. I am absolutely with you separators not to belong to the key/value in general. But especially with meta scopes you'll run into trouble with that as the position directly in front of , is not scoped with the meta of this area anymore which is required for completions.

This is the reason why many default languages started to include the \n especially in comments, because otherwise you'll get normal completions at the end of each comment line, because ST doesn't know about the comment there.