Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

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

Merged
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 join this conversation on GitHub. Already have an account? Sign in to comment
Labels
None yet
Projects
None yet
Development

Successfully merging this pull request may close these issues.

2 participants