Skip to content

Commit

Permalink
Update variable name for source to avoid function name conflict (#1105)
Browse files Browse the repository at this point in the history
```
Error detected while processing function clap#[45]..clap#open_provider[23]..<SNR>45_detect_source_type:
line    1:
E705: Variable name conflicts with existing function: Source
```
  • Loading branch information
phongnh authored Dec 12, 2024
1 parent 2be3d12 commit 66b6154
Show file tree
Hide file tree
Showing 2 changed files with 8 additions and 8 deletions.
6 changes: 3 additions & 3 deletions autoload/clap.vim
Original file line number Diff line number Diff line change
Expand Up @@ -125,15 +125,15 @@ function! s:inject_default_impl_is_ok(provider_info) abort
endfunction

function! s:detect_source_type() abort
let Source = g:clap.provider._().source
let source_ty = type(Source)
let ClapProviderSource = g:clap.provider._().source
let source_ty = type(ClapProviderSource)

if source_ty == v:t_string
return g:__t_string
elseif source_ty == v:t_list
return g:__t_list
elseif source_ty == v:t_func
let string_or_list = Source()
let string_or_list = ClapProviderSource()
if type(string_or_list) == v:t_string
return g:__t_func_string
elseif type(string_or_list) == v:t_list
Expand Down
10 changes: 5 additions & 5 deletions autoload/clap/api/clap.vim
Original file line number Diff line number Diff line change
Expand Up @@ -366,17 +366,17 @@ function! s:init_provider() abort
endfunction

function! provider._apply_source() abort
let Source = self._().source
let ClapProviderSource = self._().source

if self.source_type == g:__t_string
return s:_system(Source)
return s:_system(ClapProviderSource)
elseif self.source_type == g:__t_list
" Use copy here, otherwise it could be one-off List.
return copy(Source)
return copy(ClapProviderSource)
elseif self.source_type == g:__t_func_string
return s:_system(Source())
return s:_system(ClapProviderSource())
elseif self.source_type == g:__t_func_list
return copy(Source())
return copy(ClapProviderSource())
else
return ['source() must return a List or a String if it is a Funcref']
endif
Expand Down

0 comments on commit 66b6154

Please sign in to comment.