Youcompleteme: Commit 6ba6b56 breaks DelimitMate 'delimitMateBackspace' plugin functionality

Created on 28 Jun 2017  路  10Comments  路  Source: ycm-core/YouCompleteMe

Issue Prelude

Please complete these steps and check these boxes (by putting an x inside
the brackets) _before_ filing your issue:

  • [x] I have read and understood YCM's [CONTRIBUTING][cont] document.
  • [x] I have read and understood YCM's [CODE_OF_CONDUCT][code] document.
  • [x] I have read and understood YCM's [README][readme], especially the
    [Frequently Asked Questions][faq] section.
  • [x] I have searched YCM's issue tracker to find issues similar to the one I'm
    about to report and couldn't find an answer to my problem. ([Example Google
    search.][search])
  • [ ] If filing a bug report, I have included the output of vim --version.
  • [ ] If filing a bug report, I have included the output of :YcmDebugInfo.
  • [ ] If filing a bug report, I have attached the contents of the logfiles using
    the :YcmToggleLogs command.
  • [ ] If filing a bug report, I have included which OS (including specific OS
    version) I am using.
  • [ ] If filing a bug report, I have included a minimal test case that reproduces
    my issue, including what I expected to happen and what actually happened.
  • [ ] If filing a installation failure report, I have included the entire output
    of install.py (or cmake/make/ninja) including its invocation
  • [x] I understand this is an open-source project staffed by volunteers and
    that any help I receive is a selfless, heartfelt _gift_ of their free time. I
    know I am not entitled to anything and will be polite and courteous.
  • [x] I understand my issue may be closed if it becomes obvious I didn't
    actually perform all of these steps.

Thank you for adhering to this process! It ensures your issue is resolved
quickly and that neither your nor our time is needlessly wasted.

Issue Details

By the 'delimitMateBackspace' functionality when we delete an opening delimiter with "\

Running the :DelimitMateTest with and without YCM plugin activated we see the remapping of "\

without YCM:
i "\delimitMateBS
Last set from ~/.vim/bundle/delimitMate/plugin/delimitMate.vim

with YCM:
i "\98_OnDeleteChar( "\" )
Last set from ~/.vim/bundle/YouCompleteMe/autoload/youcompleteme.vim

  • What did you do?

Include steps to reproduce here.

Have https://github.com/Raimondi/delimitMate plugin and YouCompleteMe plugin active, for example open a PHP file.

  • What did you expect to happen?

write:

function test ( | )

then press "\

function test |

  • What actually happened?

write:

function test ( | )

then press "\

function test (|

I think its this line of code added on last commit

https://github.com/Valloric/YouCompleteMe/blob/master/autoload/youcompleteme.vim#L252

Maybe have an option to add or remove keys to this functionality?

Thanks in advance, sorry for bad English.

Most helpful comment

@micbou Any advances in merging this fix to upstream?

All 10 comments

@micbou I think we should do something like https://github.com/tpope/vim-endwise/blob/master/plugin/endwise.vim#L113-L116 where if the key is already mapped we just concatenate the actions and do both of them; and maybe we should also check if pumvisible?

@vheon Thanks for the link. I implemented a similar approach in this branch. It seems to work fine with the DelimitMate plugin. @davidsierradz Could you try it out?

@davidsierradz As a workaround you could try using auto-pairs. I'm using it and didn't stumble upon this problem.

@micbou, downloaded and tested the branch, I think its working good, thanks.

@micbou Any advances in merging this fix to upstream?

Anybody who wanted to use this feature can just

  1. clone the repo locally,
  2. switch to the branch which has fixed the problem and
  3. merge that branch locally and
  4. then push it to their remote and
  5. use than in .vimrc

Sorry for the lack of answer. I am not really satisfied with the solution because it adds the OnDeleteChar function to the <BS> key even if the user remapped it to something that have nothing to do with deleting characters in insert mode. I think a better approach would be to expose the OnDeleteChar function through a mapping and let users remap the <BS> key as follows:

imap <BS> <Plug>YcmOnDeleteChar<Plug>delimiteMateBS

where <Plug>YcmOnDeleteChar is the mapping exposing OnDeleteChar. This would be mentioned in the FAQ. Thoughts?

In the meantime, a workaround is to add the following to your vimrc:

imap <silent> <BS> <C-R>=YcmOnDeleteChar()<CR><Plug>delimitMateBS

function! YcmOnDeleteChar()
  if pumvisible()
    return "\<C-y>"
  endif
  return "" 
endfunction

@davidsierradz we've changed the YCM completion implementation in #3645 could you try that PR and see if it resolves this issue ? I don't use any of these plugins delimit plugins.

@puremourning I arrived here because of this issue. I updated YouCompleteMe and looks like delimitMate backspace works as intended without work arounds.

Great thanks.

Was this page helpful?
0 / 5 - 0 ratings