Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Fix the problem of key bindings in finder buffers #4122

Open
wants to merge 1 commit into
base: master
Choose a base branch
from
Open
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
32 changes: 32 additions & 0 deletions autoload/youcompleteme/finder.vim
Original file line number Diff line number Diff line change
Expand Up @@ -243,6 +243,38 @@ function! youcompleteme#finder#FindSymbol( scope ) abort
autocmd WinLeave <buffer> call s:Cancel()
autocmd CmdLineEnter <buffer> call s:Cancel()
augroup END
" override all the global mappings in the finder buffer
" by remapping each previously mapped key sequence to itself
" (still preserve the previously defined buffer-local mappings)
if exists( '*maplist' ) && exists( '*mapset' )
let bufmapsave = maplist()->filter( 'v:val.buffer == 1' )
for mapitem in map(
\ maplist()->filter( 'v:val.buffer == 0' ),
\ { _, val -> val->extend( #{ expr: 0, noremap: 1, rhs: val.lhs, buffer: 1, silent: 1 } ) } )
call mapset( mapitem )
endfor
for mapitem in bufmapsave
call mapset( mapitem )
endfor
else
let bufmapsave = []
let mapitems = []
for mapitem in split( execute( 'map | map!' ), '\n\+' )
let [ mapmode, lhs, attr; _ ] = split( mapitem, '\s\+', 1 )
if attr =~ '^[*&]\?@'
call add( bufmapsave, lhs )
else
call add( mapitems, [ mapmode, lhs ] )
endif
endfor
for mapitem in mapitems
let [ mapmode, lhs ] = mapitem
if index( bufmapsave, lhs ) == -1
let mapcmd = mapmode == '!' ? 'noremap!' : ( mapmode . 'noremap' )
silent exec mapcmd . ' <buffer> <silent> ' . lhs . ' ' . lhs
endif
endfor
endif
startinsert
endfunction

Expand Down