nerdtree

A tree explorer plugin for vim.
Index Commits Files Refs
commit f63fb6984f9cd07cf723c3e2e20f6ccc0aad48c2
parent a1fa4a33bf16b6661e502080fc97788bb98afd35
Author: Phil Runninger <PhilRunninger@users.noreply.github.com>
Date:   Mon,  1 Mar 2021 09:34:54 -0500

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.
Diffstat:
MCHANGELOG.md | 1+
Mlib/nerdtree/key_map.vim | 6+++---
Mlib/nerdtree/notifier.vim | 4++--
Mlib/nerdtree/path.vim | 8++++----
4 files changed, 10 insertions(+), 9 deletions(-)
diff --git a/CHANGELOG.md b/CHANGELOG.md
@@ -5,6 +5,7 @@
         - **.PATCH**: Pull Request Title (PR Author) [PR Number](Link to PR)
 -->
 #### 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)
 - **.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)
diff --git a/lib/nerdtree/key_map.vim b/lib/nerdtree/key_map.vim
@@ -66,11 +66,11 @@ endfunction
 "FUNCTION: KeyMap.invoke() {{{1
 "Call the KeyMaps callback function
 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
-        call Callback(a:1)
+        call l:Callback(a:1)
     else
-        call Callback()
+        call l:Callback()
     endif
 endfunction
 
diff --git a/lib/nerdtree/notifier.vim b/lib/nerdtree/notifier.vim
@@ -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)
 
     for Listener in s:Notifier.GetListenersForEvent(a:event)
-        let Callback = type(Listener) == type(function('tr')) ? Listener : function(Listener)
-        call Callback(event)
+        let l:Callback = type(Listener) == type(function('tr')) ? Listener : function(Listener)
+        call l:Callback(event)
     endfor
 endfunction
 
diff --git a/lib/nerdtree/path.vim b/lib/nerdtree/path.vim
@@ -459,10 +459,10 @@ function! s:Path.ignore(nerdtree)
             endif
         endfor
 
-        for Callback in g:NERDTree.PathFilters()
-            let Callback = type(Callback) ==# type(function('tr')) ? Callback : function(Callback)
-            if Callback({'path': self, 'nerdtree': a:nerdtree})
-                return 1
+        for l:Callback in g:NERDTree.PathFilters()
+            let l:Callback = type(l:Callback) ==# type(function('tr')) ? l:Callback : function(l:Callback)
+            if l:Callback({'path': self, 'nerdtree': a:nerdtree})
+               return 1
             endif
         endfor
     endif