From df4f9342b974c61860bfafd521faff56f62ceac4 Mon Sep 17 00:00:00 2001 From: Matthew Malcomson Date: Tue, 28 Mar 2017 19:42:44 +0100 Subject: Make 'langnoremap' apply directly after a map We were initially checking whether to apply 'langmap' translation based on typebuf.tb_maplen. This gets set to 0 on the last byte of a map when the del_typebuf() function is called, which means that the option was not working for the last character of a mapping. For this reason, we switched to using KeyTyped to decide whether to apply the transformation or not in commit 53da57d27. Substituting one for the other isn't enough, because KeyTyped isn't set until vgetorpeek() is returning. This means 'langmap' translations are not applied when searching for characters to map in the vgetorpeek() function if the *previous* key was not typed. We can't assert that both hold, as we would then *not* apply the transformation when looking for a map starting with the first typed key after a previously expanded map (as KeyTyped would be `false` from the previously expanded map, and not yet reset). Hence we assert that if we are looking for the mapping while in vgetorpeek(), the map length should be zero, otherwise, KeyTyped must be `true`. This is implemented by checking for the variable `vgetc_busy`. --- src/nvim/macros.h | 2 +- 1 file changed, 1 insertion(+), 1 deletion(-) (limited to 'src') diff --git a/src/nvim/macros.h b/src/nvim/macros.h index a98c1e05a0..0406574990 100644 --- a/src/nvim/macros.h +++ b/src/nvim/macros.h @@ -75,7 +75,7 @@ do { \ if (*p_langmap \ && (condition) \ - && (p_lrm || KeyTyped) \ + && (p_lrm || (vgetc_busy ? typebuf_maplen() == 0 : KeyTyped)) \ && !KeyStuffed \ && (c) >= 0) \ { \ -- cgit