rickhowe / diffchar.vim

Highlight the exact differences, based on characters and words
http://www.vim.org/scripts/script.php?script_id=4932
MIT License
217 stars 10 forks source link

Error: <SNR>25_ShowDiffCharPair[29]..<SNR>25_HighlightDiffCharPair - Key not present #9

Closed krayon closed 7 years ago

krayon commented 7 years ago

Version: VIM version 8.0.851 OS: Artix Linux (basically ArchLinux/Manjaro with no SystemD) VIMRC: none

Using 2 files:

/tmp/fileA

First line
TWo capital letters at start
TWo capital letters at start

/tmp/fileB

EXTRA LINE
First line
two capital letters at start
two capital letters at start

Diff of the 2:

--- /tmp/fileA  2017-09-04 15:29:46.480274794 +1000
+++ /tmp/fileB  2017-09-04 15:30:39.450275813 +1000
@@ -1,3 +1,4 @@
+EXTRA LINE
 First line
-TWo capital letters at start
-TWo capital letters at start
+two capital letters at start
+two capital letters at start

Command:

vimdiff /tmp/file[AB]

Actions:

Error:

Error detected while processing function <SNR>25_UpdateDiffChar[51]..<SNR>25_ClearDiffChar:
line    3:
E716: Key not present in Dictionary: 2
Press ENTER or type command to continue
Error detected while processing function <SNR>25_UpdateDiffChar[51]..<SNR>25_ClearDiffChar:
line    3:
E116: Invalid arguments for function filter(t:DChar.mid[a:key][l], 'index(mx, v:val) != -1'),'matchdelete(v:val)')
Press ENTER or type command to continue
Error detected while processing function <SNR>25_UpdateDiffChar[51]..<SNR>25_ClearDiffChar:
line    3:
E116: Invalid arguments for function map
Press ENTER or type command to continue
Error detected while processing function <SNR>25_UpdateDiffChar[51]..<SNR>25_ClearDiffChar:
line    5:
E716: Key not present in Dictionary: 2
Press ENTER or type command to continue
Error detected while processing function <SNR>25_UpdateDiffChar[51]..<SNR>25_ClearDiffChar:
line    6:
E716: Key not present in Dictionary: 2
Press ENTER or type command to continue
rickhowe commented 7 years ago

Thanks for letting me know the error. I found the cause of the problem. Until the next update, you could try to change autoload/diffchar.vim as follows as a workaround.

--- dc69a.vim   2017-08-22 22:06:14.418686100 +0900
+++ dc69a2.vim  2017-09-04 15:53:08.004377600 +0900
@@ -702,9 +702,11 @@
            " if # of lines was not changed, firstly try to clear
            " highlights of changed lines and show them again,
            " and then if no highlight remains, clear event and DChar
+           let [cl1, cl2] = exists('t:DChar.dml') ?
+                                   \s:DiffModeLines(a:key, chl) : [chl, chl]
            for k in [1, 2]
                exec 'noautocmd ' . t:DChar.win[k] . 'wincmd w'
-               call s:ClearDiffChar(k, chl)
+               call s:ClearDiffChar(k, cl{k})
            endfor
            if t:DChar.dpv | call s:ClearDiffCharPair() | endif
            exec 'noautocmd ' . t:DChar.win[a:key] . 'wincmd w'

Hope this helps.

bartlibert commented 7 years ago

I had the same issue and I can confirm the workaround is working

krayon commented 7 years ago

I too can confirm the above fixes the issue.

@rickhowe Thanks SO much for the (rapid) fix, and for diffchar! :-D I would have fixed it myself and submitted a PR but I have exactly zero experience writing vim plugins and looking just did my head in :-/

levouh commented 2 years ago

@rickhowe was something ever merged for this (curious as this issue is closed, but I do not see an associated PR)? I am getting:

Error detected while processing DiffUpdated Autocommands for "*"..function <SNR>70_UpdateDiffChar[4]..<SNR>70_RedrawDiffChar[49]..<SNR>70_ResetDiffChar:                                                                                                                                                                                                                                                                                                                                       
line   16:                                                                                                                                                                                                                                                                                                                                                                                                                                                                                     
E716: Key not present in Dictionary: "1"

and am not sure if I should make a new issue or not.

Don't currently have a way to reproduce the issue I'm seeing, but will do so if I need to make a new issue.

rickhowe commented 2 years ago

Thanks. I tried on gvim9.0 and vim8.2 on Windows 10, but the problem looks fixed with the diffchar 9.01. The problem can happen on your Linux system?

levouh commented 2 years ago

Thanks. I tried on gvim9.0 and vim8.2 on Windows 10, but the problem looks fixed with the diffchar 9.01. The problem can happen on your Linux system?

I'm using Neovim on Linux, but let me figure out a way to reproduce the bug and make a new issue.

rickhowe commented 2 years ago

I just tried to reproduce what krayon commented in this issue (see top). Nvim6.0 also has no problem in my Windows 10.

levouh commented 2 years ago

I just tried to reproduce what krayon commented in this issue (see top). Nvim6.0 also has no problem in my Windows 10.

Yes, I believe my issue is different. I just wanted to know if there was a fix merged for this issue before making a new one - which it seems like there was.

I will make a new issue with different reproduction steps.