Shopify / theme-check

The Ultimate Shopify Theme Linter
Other
340 stars 96 forks source link

[Intelligent code completion] Do not log an error when preceding `assign`ed value is not mentioned in the docs #682

Closed Poitrin closed 1 year ago

Poitrin commented 1 year ago

Describe the bug :+1: When using e.g. …

… suggestions work and no error appears:

13-48-nf3mu-f335o

:-1: However, when using values that are not explicitly mentioned in the docs, e.g. …

… only default suggestions are shown, and when adding/removing characters, errors might happen:

{%- liquid
  assign columns_mobile_int = section.settings.columns_mobile
  assign show_mobile_slider = false
-%}

{%- if show_mobile_slider

13-49-x9cab-9q6mh

Expected No matter the assigned value, code completion should not crash.

Actual When certain values are assigned, code completion crashes.

Stack trace

[completion error] error: undefined method `name' for nil:NilClass
/lib/theme_check/language_server/completion_providers/assignments_completion_provider.rb:19:in `block in completions'
/lib/theme_check/language_server/completion_providers/assignments_completion_provider.rb:17:in `each'
/lib/theme_check/language_server/completion_providers/assignments_completion_provider.rb:17:in `map'
/lib/theme_check/language_server/completion_providers/assignments_completion_provider.rb:17:in `completions'
/lib/theme_check/language_server/completion_engine.rb:16:in `block in completions'
/lib/theme_check/language_server/completion_engine.rb:16:in `each'
/lib/theme_check/language_server/completion_engine.rb:16:in `flat_map'
/lib/theme_check/language_server/completion_engine.rb:16:in `completions'
/lib/theme_check/language_server/handler.rb:145:in `on_text_document_completion'
/lib/theme_check/language_server/server.rb:138:in `handle_message'
/lib/theme_check/language_server/server.rb:109:in `block in handle_messages'
/lib/theme_check/language_server/server.rb:105:in `loop'
/lib/theme_check/language_server/server.rb:105:in `handle_messages'
/lib/theme_check/language_server/server.rb:99:in `block (2 levels) in start_handler_threads'

Debugging information