
Patch 7.2.374 allows VIM::evaluate() to return Ruby arrays or hashes instead of strings if the Vim expression results in a list or dictionary. This, unfortunately, did break TwitVim because TwitVim does the following:
keys = VIM.evaluate('keys(a:parms)') keys = keys.split(/\n/)If the parms dictionary has keys "user", "text", and "status", prior to patch 7.2.374, VIM.evaluate() will return "user\ntext\nstatus" and the next line will split it into the array ["user", "text", "status"]. After patch 7.2.374, VIM.evaluate() returns ["user", "text", "status"], causing the next line to hit a Ruby error because a Ruby array doesn't have a split() method.
How do we solve this problem? At first, I was thinking of checking for this Vim patch using a conditional like this:
v:version > 702 || v:version == 702 && has("patch374")In other words, Vim 7.3 and later are guaranteed to have patch 7.2.374 and we only check for the patch itself if the Vim version is 7.2. If I stick this expression into VIM.evaluate(), it'll return "1" if that patch is present and "0" otherwise. Then it occurred to me that there are two better ways to deal with this:
1. Make the Vim expression return a string regardless by doing an explicit join on the array:
keys = VIM.evaluate('join(keys(a:parms), "\n")') keys = keys.split(/\n/)2. Use Ruby's type introspection to see if a split is needed:
keys = VIM.evaluate('keys(a:parms)') keys = keys.split(/\n/) if keys.is_a? StringI prefer the second approach because it is more efficient and a few years into the future, once everyone has upgraded their Vim installations past this patch, we can clean up the code easily by removing the second line. Thus, this fix is in TwitVim revision 82.