Skip to content

Commit

Permalink
Check for self consistency before self:is_initialized() (#110)
Browse files Browse the repository at this point in the history
  • Loading branch information
fabiomcosta committed Jul 9, 2023
1 parent 5a9b041 commit e9b8fa8
Showing 1 changed file with 10 additions and 10 deletions.
20 changes: 10 additions & 10 deletions lua/distant/init.lua
Original file line number Diff line number Diff line change
Expand Up @@ -520,18 +520,10 @@ end
--- @param settings distant.plugin.Settings
--- @param opts? {wait?:integer}
function M:setup(settings, opts)
opts = opts or {}
log.fmt_trace('distant:setup(settings = %s, opts = %s)', settings, opts)
if self:is_initialized() then
log.warn(table.concat({
'distant:setup() called more than once!',
'Ignoring new call to setup.'
}, ' '))
return
end

-- Ensure something is populated
opts = opts or {}
settings = settings or {}
log.fmt_trace('distant:setup(settings = %s, opts = %s)', settings, opts)

-- Check if using the old distant.setup versus distant:setup
if getmetatable(self) ~= M then
Expand All @@ -543,6 +535,14 @@ function M:setup(settings, opts)
}, '\n'))
return
end

if self:is_initialized() then
log.warn(table.concat({
'distant:setup() called more than once!',
'Ignoring new call to setup.'
}, ' '))
return
end

-- Detect if old setup is being used by checking for a '*' field
if settings['*'] ~= nil then
Expand Down

0 comments on commit e9b8fa8

Please sign in to comment.