Skip to content

Commit 9c7299d

Browse files
committed
🐛 Fix mapping restore issue
1 parent 9c17912 commit 9c7299d

File tree

1 file changed

+12
-3
lines changed

1 file changed

+12
-3
lines changed

autoload/fall/internal/mapping.vim

Lines changed: 12 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -5,13 +5,22 @@ function! fall#internal#mapping#store() abort
55
let s:saved_maps = maplist()->filter({ _, m -> m.mode ==# 'c' || m.mode ==# '!' })
66
endfunction
77

8+
" NOTE:
9+
"
10+
" It seems restore step must be called twice to restore the mappings correctly.
11+
" Otherwise, mappings with recursive references are not restored correctly.
12+
"
13+
" For example:
14+
"
15+
" cnoremap <Up> <C-p>
16+
" cnoremap <C-p> <Up>
17+
"
818
function! fall#internal#mapping#restore()
919
if !exists('s:saved_maps')
1020
return
1121
endif
1222
cmapclear
13-
for l:m in s:saved_maps
14-
call mapset(l:m)
15-
endfor
23+
call foreach(s:saved_maps, {_, m -> mapset(m)})
24+
call foreach(s:saved_maps, {_, m -> mapset(m)})
1625
unlet s:saved_maps
1726
endfunction

0 commit comments

Comments
 (0)