Skip to content
This repository was archived by the owner on Feb 12, 2025. It is now read-only.

fix(apply_shim): add nil check for opts #177

Merged
merged 1 commit into from
Nov 4, 2024
Merged

fix(apply_shim): add nil check for opts #177

merged 1 commit into from
Nov 4, 2024

Conversation

TheLeoP
Copy link
Contributor

@TheLeoP TheLeoP commented Nov 4, 2024

#175 does not check for possible nil value of opts on add_shim (that may come from :h dressing_get_config()). Add nil check

Context

#175 added apply_shim to maintain backwards compatibility, but it doesn't check if opts is nil before trying to access it. It may be nil since :h dressing_get_config() allows for a nil return value.

Description

A nil check is added

Test Plan

My config was broken after #175 since I have the following on my oil setup.

{
  -- ...
  input = {
    get_config = function(opts)
      if opts.prompt == "cmd: " then
        return {
          -- some custom options
        }
      end
    end,
  },
  -- ...
}

The function returns nil to fallback to the default config whe prompt is not cmd: . With this config, calling vim.ui.input({}, function() end) resulted in an error before this PR and works as expected after it.

@github-actions github-actions bot requested a review from stevearc November 4, 2024 21:33
@stevearc
Copy link
Owner

stevearc commented Nov 4, 2024

Thanks for the fix!

@stevearc stevearc merged commit 6ef1ca4 into stevearc:master Nov 4, 2024
9 checks passed
@TheLeoP TheLeoP deleted the fix_get_config branch November 4, 2024 23:12
Sign up for free to subscribe to this conversation on GitHub. Already have an account? Sign in.
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants