Put Callback function variables in local scope. (#1230)

* Put `Callback` function variables in local scope.

This change prevents conflict with other `Callback` functions that are
defined elsewhere in global scope.

* Update version number in change log.
This commit is contained in:
Phil Runninger 2021-03-01 09:34:54 -05:00 committed by GitHub
parent a1fa4a33bf
commit f63fb6984f
No known key found for this signature in database
GPG Key ID: 4AEE18F83AFDEB23
4 changed files with 10 additions and 9 deletions

View File

@ -5,6 +5,7 @@
- **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR) - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
--> -->
#### 6.10 #### 6.10
- **.8**: Put `Callback` function variables in local scope. [#1230](https://github.com/preservim/nerdtree/pull/1230)
- **.7**: Fix mouse-clicking a file to open it. (PhilRunninger) [#1225](https://github.com/preservim/nerdtree/pull/1225) - **.7**: Fix mouse-clicking a file to open it. (PhilRunninger) [#1225](https://github.com/preservim/nerdtree/pull/1225)
- **.6**: Restore the default behavior of the <CR> key. (PhilRunninger) [#1221](https://github.com/preservim/nerdtree/pull/1221) - **.6**: Restore the default behavior of the <CR> key. (PhilRunninger) [#1221](https://github.com/preservim/nerdtree/pull/1221)
- **.5**: Fix `{'keepopen':0}` in NERDTreeCustomOpenArgs (PhilRunninger) [#1217](https://github.com/preservim/nerdtree/pull/1217) - **.5**: Fix `{'keepopen':0}` in NERDTreeCustomOpenArgs (PhilRunninger) [#1217](https://github.com/preservim/nerdtree/pull/1217)

View File

@ -66,11 +66,11 @@ endfunction
"FUNCTION: KeyMap.invoke() {{{1 "FUNCTION: KeyMap.invoke() {{{1
"Call the KeyMaps callback function "Call the KeyMaps callback function
function! s:KeyMap.invoke(...) function! s:KeyMap.invoke(...)
let Callback = type(self.callback) ==# type(function('tr')) ? self.callback : function(self.callback) let l:Callback = type(self.callback) ==# type(function('tr')) ? self.callback : function(self.callback)
if a:0 if a:0
call Callback(a:1) call l:Callback(a:1)
else else
call Callback() call l:Callback()
endif endif
endfunction endfunction

View File

@ -15,8 +15,8 @@ function! s:Notifier.NotifyListeners(event, path, nerdtree, params)
let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params) let event = g:NERDTreeEvent.New(a:nerdtree, a:path, a:event, a:params)
for Listener in s:Notifier.GetListenersForEvent(a:event) for Listener in s:Notifier.GetListenersForEvent(a:event)
let Callback = type(Listener) == type(function('tr')) ? Listener : function(Listener) let l:Callback = type(Listener) == type(function('tr')) ? Listener : function(Listener)
call Callback(event) call l:Callback(event)
endfor endfor
endfunction endfunction

View File

@ -459,10 +459,10 @@ function! s:Path.ignore(nerdtree)
endif endif
endfor endfor
for Callback in g:NERDTree.PathFilters() for l:Callback in g:NERDTree.PathFilters()
let Callback = type(Callback) ==# type(function('tr')) ? Callback : function(Callback) let l:Callback = type(l:Callback) ==# type(function('tr')) ? l:Callback : function(l:Callback)
if Callback({'path': self, 'nerdtree': a:nerdtree}) if l:Callback({'path': self, 'nerdtree': a:nerdtree})
return 1 return 1
endif endif
endfor endfor
endif endif