justmao945 / vim-clang

Clang completion plugin for vim
ISC License
357 stars 47 forks source link

Since vim 8.2.2426,7 changing windows not allowed in complete function #140

Closed mckellygit closed 3 years ago

mckellygit commented 3 years ago

@justmao945 hi, Thank you for this awesome plugin.

Here is an update needed since vim changes in 8.2.2426, 7 Not sure if there are better things to check/do other than just skipping these ?

Without this I get many - Error detected while processing function ClangComplete[2]..31_ClangComplete[62]..31_HasPreviewAbove: E565: Not allowed to change text or change window

thx, -m

mckellygit commented 3 years ago

I think there are a few other places where this can happen. I will continue to look and update this PR. For example I see this from diagnostic window - Error detected while processing function ClangComplete[2]..31_ClangComplete[67]..31_DiagnosticsWindowOpen: line 28: E565: Not allowed to change text or change window: silent keepalt keepjumps keepmarks rightbelow sbuffer 2

Might have to start disagnostic window some other way ...

mckellygit commented 3 years ago

Perhaps moving the diagnosticswindow to after complete is done, as in -

    au CompleteDone <buffer> if ! empty(b:clang_cache['diagnostics']) && b:clang_state['state'] == 'ready' | call <SID>DiagnosticsWindowOpen(expand('%:p:.'), b:clang_cache['diagnostics']) | endif

would be ok ?

mckellygit commented 3 years ago

I just put that logic into ShrinkPreviewWindow()

justmao945 commented 3 years ago

Hi @mckellygit thank you for your nice work ! better to rename ShrinkPreviewWindow to OpenDiagAndShrinkPreviewWindow ?

mckellygit commented 3 years ago

ok, good idea. I just changed the name. But should we always do this now and not do the -

    if !has("patch-8.2.2426")
        call s:DiagnosticsWindowOpen(expand('%:p:.'), b:clang_cache['diagnostics'])
    endif

If so then I'll remove these lines and the version check in OpenDiagAndShrinkPreviewWindow() thx, -m

justmao945 commented 3 years ago

It seems that we can remove the test line if !has("patch-8.2.2426"), and keep compatible with version has 'patch-8.2.2426' or not

mckellygit commented 3 years ago

ok, I removed the - call s:DiagnosticsWindowOpen() So now that only happens in ShrinkPreviewWindow() from the CompleteDone autocmd. It changes a little bit when it shows up (after the complete func ends) but its consistent and seems ok to me. thx, -m

mckellygit commented 3 years ago

Thanks again.