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

Undefined variable: b:traverser #12

Closed
char101 opened this issue Feb 5, 2019 · 2 comments
Closed

Undefined variable: b:traverser #12

char101 opened this issue Feb 5, 2019 · 2 comments

Comments

@char101
Copy link

char101 commented Feb 5, 2019

Hi,

I frequently encounter this errors:

Error detected while processing function pear_tree#insert_mode#OnInsertCharPre[1]..<SNR>201_CorrectTraverser:
line    2:
E121: Undefined variable: b:traverser
Error detected while processing function pear_tree#insert_mode#OnInsertCharPre[1]..<SNR>201_CorrectTraverser:
line    2:
E121: Undefined variable: b:traverser
Error detected while processing function pear_tree#insert_mode#OnInsertCharPre[1]..<SNR>201_CorrectTraverser:
line    2:
E121: Undefined variable: b:traverser
Error detected while processing function pear_tree#insert_mode#OnInsertCharPre[1]..<SNR>201_CorrectTraverser:
line    2:
E121: Undefined variable: b:traverser
Error detected while processing function pear_tree#insert_mode#OnInsertCharPre[1]..<SNR>201_CorrectTraverser:
line    2:
E121: Undefined variable: b:traverser

Unfortunately I cannot consistently reproduce this error. It seems to me that the variable creation is delayed, because if I exit and reenter INSERT mode, the variable b:traverser is defined.

@tmsvg
Copy link
Owner

tmsvg commented Apr 9, 2019

The b:traverser variable is defined as soon as insert mode is first entered, so it's not clear to me how you would be getting this error, since OnInsertCharPre() should only be called after you enter insert mode. Maybe something in your config is preventing the InsertEnter autocmd from triggering (see :noautocmd or :eventignore).

This doesn't really sound like a Pear Tree bug to me, but you could try updating to the latest version and see if you still experience this issue.

@char101
Copy link
Author

char101 commented Apr 10, 2019

I don't experience the error again after adding these lines. It doesn't always happens and probably happens after switching buffers so most likely a problem of concurrent execution.

diff --git a/autoload/pear_tree/insert_mode.vim b/autoload/pear_tree/insert_mode.vim
index 8a53e08..75a2ce2 100644
--- a/autoload/pear_tree/insert_mode.vim
+++ b/autoload/pear_tree/insert_mode.vim
@@ -36,6 +36,7 @@ endfunction


 function! s:CorrectTraverser() abort
+    call pear_tree#insert_mode#OnInsertEnter()
     if s:lost_track
         call b:traverser.Reset()
         let s:traverser_start_pos = b:traverser.TraverseBuffer([1, 0], [line('.'), col('.') - 1])
@@ -61,6 +62,7 @@ endfunction


 function! pear_tree#insert_mode#OnCursorMovedI() abort
+    call pear_tree#insert_mode#OnInsertEnter()
     let l:new_line = line('.')
     let l:new_col = col('.')
     if l:new_line != s:current_line || l:new_col < s:current_column

@char101 char101 closed this as completed Apr 10, 2019
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

No branches or pull requests

2 participants