Mercurial > vim
comparison src/getchar.c @ 4865:d84833983de7 v7.3.1179
updated for version 7.3.1179
Problem: When a global mapping starts with the same characters as a
buffer-local mapping Vim waits for a character to be typed to find
out whether the global mapping is to be used. (Andy Wokula)
Solution: Use the local mapping without waiting. (Michael Henry)
author | Bram Moolenaar <bram@vim.org> |
---|---|
date | Wed, 12 Jun 2013 21:00:26 +0200 |
parents | d67e292af6f9 |
children | 1cf89d38aa76 |
comparison
equal
deleted
inserted
replaced
4864:9595cfcf8d2d | 4865:d84833983de7 |
---|---|
1922 int keylen; | 1922 int keylen; |
1923 char_u *s; | 1923 char_u *s; |
1924 mapblock_T *mp; | 1924 mapblock_T *mp; |
1925 #ifdef FEAT_LOCALMAP | 1925 #ifdef FEAT_LOCALMAP |
1926 mapblock_T *mp2; | 1926 mapblock_T *mp2; |
1927 int expecting_global_mappings; | |
1927 #endif | 1928 #endif |
1928 mapblock_T *mp_match; | 1929 mapblock_T *mp_match; |
1929 int mp_match_len = 0; | 1930 int mp_match_len = 0; |
1930 int timedout = FALSE; /* waited for more than 1 second | 1931 int timedout = FALSE; /* waited for more than 1 second |
1931 for mapping to complete */ | 1932 for mapping to complete */ |
2103 #endif | 2104 #endif |
2104 #ifdef FEAT_LOCALMAP | 2105 #ifdef FEAT_LOCALMAP |
2105 /* First try buffer-local mappings. */ | 2106 /* First try buffer-local mappings. */ |
2106 mp = curbuf->b_maphash[MAP_HASH(local_State, c1)]; | 2107 mp = curbuf->b_maphash[MAP_HASH(local_State, c1)]; |
2107 mp2 = maphash[MAP_HASH(local_State, c1)]; | 2108 mp2 = maphash[MAP_HASH(local_State, c1)]; |
2109 expecting_global_mappings = (mp && mp2); | |
2108 if (mp == NULL) | 2110 if (mp == NULL) |
2109 { | 2111 { |
2110 mp = mp2; | 2112 mp = mp2; |
2111 mp2 = NULL; | 2113 mp2 = NULL; |
2112 } | 2114 } |
2126 #ifdef FEAT_LOCALMAP | 2128 #ifdef FEAT_LOCALMAP |
2127 mp->m_next == NULL ? (mp = mp2, mp2 = NULL) : | 2129 mp->m_next == NULL ? (mp = mp2, mp2 = NULL) : |
2128 #endif | 2130 #endif |
2129 (mp = mp->m_next)) | 2131 (mp = mp->m_next)) |
2130 { | 2132 { |
2133 #ifdef FEAT_LOCALMAP | |
2134 if (expecting_global_mappings && mp2 == NULL) | |
2135 { | |
2136 /* This is the first global mapping. If we've | |
2137 * got a complete buffer-local match, use it. */ | |
2138 if (mp_match) | |
2139 break; | |
2140 expecting_global_mappings = FALSE; | |
2141 } | |
2142 #endif | |
2131 /* | 2143 /* |
2132 * Only consider an entry if the first character | 2144 * Only consider an entry if the first character |
2133 * matches and it is for the current state. | 2145 * matches and it is for the current state. |
2134 * Skip ":lmap" mappings if keys were mapped. | 2146 * Skip ":lmap" mappings if keys were mapped. |
2135 */ | 2147 */ |