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

:UndoTreeToggle causes E121 and E116 #112

Open
Xmgplays opened this issue Feb 6, 2020 · 5 comments
Open

:UndoTreeToggle causes E121 and E116 #112

Xmgplays opened this issue Feb 6, 2020 · 5 comments

Comments

@Xmgplays
Copy link

Xmgplays commented Feb 6, 2020

Using :UndoTreeToggle after editing a file generates this error

Error detected while processing function undotree#UndotreeToggle[11]..25[13]..27[55]..23[5]..38[65]..39:   
line   64:
E121: Undefined variable: matchwhat
E116: Invalid arguments for function <SNR>91_log

functionality does not seem to be affected.

Reproduced this using this config on neovim v0.4.3:

call plug#begin('~/.nvim/plugged')
Plug 'mbbil/undotree'
call plug#end()

Update: Same config does not cause error in vim

@trankien386
Copy link

trankien386 commented Nov 29, 2020

I also faced this issue in neovim and not in vim.

Above errors occurred when i do these actions: Opening UndoTree window using :UndoTreeToggle and :UndoTreeShow, opening Diff panel, toggling relative timestamp and undoing, redoing while UndoTree window open.

Strange enough, turn off the diff panel completely makes errors disappear when doing those actions.

let g:undotree_DiffAutoOpen = 0

Seems like the diff panel are the reason causing the error.

@freddiehaddad
Copy link

freddiehaddad commented Dec 18, 2022

I think there's a bug with the scope of the variable matchwhat and the following: undotree_HighlightChangedWithSign.

I did the following in my init.lua:

vim.g.undotree_HighlightChangedWithSign = 0

And modifed undotree.vim adding let matchwhat = '' just before the loop on line 1173 because on line 1205 the variable is out of scope.

git diff
diff --git a/autoload/undotree.vim b/autoload/undotree.vim
index 7e74ea6..477940e 100644
--- a/autoload/undotree.vim
+++ b/autoload/undotree.vim
@@ -1170,6 +1170,7 @@ function! s:diffpanel.ParseDiff(diffresult, targetBufnr) abort
     let w:undotree_diffsigns = 0
     let lineNr = 0
     let l:lastLine = line('$')
+    let matchwhat = ''
     for line in a:diffresult
         let matchnum = matchstr(line,'^[0-9,\,]*[acd]\zs\d*\ze')
         if !empty(matchnum)
@@ -1202,7 +1203,7 @@ function! s:diffpanel.ParseDiff(diffresult, targetBufnr) abort
 
         let self.changes.add += 1
         if g:undotree_HighlightChangedText
-            if matchtext != ' '
+            if matchtext != ' ' && matchwhat != ''
                 let matchtext = '\%'.lineNr.'l\V'.escape(matchtext[1:],'"\') "remove beginning space.
                 call s:log("matchadd(".matchwhat.") ->  ".matchtext)
                 call add(w:undotree_diffmatches,matchadd((matchwhat ==# 'a' ? g:undotree_HighlightSyntaxAdd : g:undotree_HighlightSyntaxChange),matchtext))

@freddiehaddad
Copy link

I will also add that switch from FISH to Zsh fixed everything without my changes. Now I'm thinking my problem was something to do with the way FISH works.

@Xmgplays Curious what shell you're using.

@gmile
Copy link

gmile commented Jan 31, 2023

Seeing an issue related to matchwhat variable, same E121 error code (context: following the short tutorial video from Primagen). And FWIW, I'm using fish-shell on macOS too.

image

@fmpisantos
Copy link

In macos when using zsh shell you need the following:
vim.cmd('set shellquote=')
vim.cmd('set shellxquote=')

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

5 participants