rhysd / clever-f.vim

Extended f, F, t and T key mappings for Vim.
https://rhysd.github.io/clever-f.vim
1.01k stars 44 forks source link

clever-f conflicts with ale #38

Closed jsfr closed 5 years ago

jsfr commented 6 years ago

I'm getting this error occasionally when using clever-f. It seems to be related to https://github.com/w0rp/ale but I'm not really sure what the error is trying to tell me nor whether the issue is with clever-f or ale.

Error detected while processing function clever_f#find_with[31]..<SNR>223_getchar[2]..<SNR>151_NeoVimCallback[29]..<SNR>112_HandleExit[43]..ale#engine#HandleLoclist[33]..ale#engine#SetResults[26]..ale#cursor#EchoCursorWarning[1]..ale#CallWithCooldown[9]..<SNR>118_EchoImpl[20]..ale#cursor#TruncatedEcho:
line   15:
E523: Not allowed here

Any help would be greatly appreciated 🙏

rhysd commented 6 years ago

Do you know the way to reproduce this? I'm also ALE user, and I think I saw the same error once. But I could not reproduce it.

rhysd commented 6 years ago

ALE outputs some messages asynchronously. And clever-f waits an input from user by getchar(). So, this issue may occur because ALE echoes some text while waiting user's input with getchar().

jsfr commented 6 years ago

I haven't been able to find the exact set of actions to reproduce this. It seems to happen semi-randomly. I think I've seen it happen more often when I'm on a "roll" in terms of moving fast between edits and movement using f or t.

rhysd commented 6 years ago

Yeah, it's a timing issue... When editing fast, ALE runs linter multiple times and it shows the results to message area. At the same time, when hitting f or t and it leads to calling getchar(), this error looks to appear.

I tried some script to reproduce this referring TruncatedEcho() function in ALE, but I couldn't. More investigation is necessary..

" Simple version of TruncatedEcho()
function! s:say_hello(_) abort
    let l:message = 'HELLO'
    let l:shortmess_options = &l:shortmess
    try
        setlocal shortmess+=T
        exec "norm! :echomsg l:message\n"
        call setpos('.', s:cursor_position)
    finally
        let &l:shortmess = l:shortmess_options
    endtry
endfunction

let s:cursor_position = getcurpos()
call timer_start(1000, function('s:say_hello'))

call getchar()
rhysd commented 6 years ago

I think this error occurs here:

https://github.com/vim/vim/blob/b9464821901623f983528acaed9e4dc2cea7387b/src/normal.c#L799

It means:

I have no idea why I cannot reproduce this problem by above script, but TruncatedEcho may need to be modified not to use :normal.

kmhofmann commented 6 years ago

I'm seeing a similar issue all the time; also an ALE user:

Error detected while processing function clever_f#find_with[31]..<SNR>141_getchar:                                                     
line    2:                                                                                                                             
E170: Missing :endwhile
rhysd commented 6 years ago

@kmhofmann Is it the entire error message? The message is different from one @jsfr and I saw.

kmhofmann commented 6 years ago

@rhysd Yep, that is the entire error message. I do see this often enough to be a bit annoying (every few minutes in a coding session), and it seems that disabling ALE makes this disappear. It's difficult to prove or to reproduce, though. The following ALE linters are enabled when this happens: clang, clangtidy, g++.

rhysd commented 6 years ago

@kmhofmann Thanks. Error I saw occurred when using f/t just after saving the buffer. How about you? And if you're ok, could you show your ALE configuration? Frequency looks different from me.

kmhofmann commented 6 years ago

Hi @rhysd - sure! The error can occur any time when editing; I did not notice any increased frequency around saving or any other action.

My base configuration: https://github.com/kmhofmann/dotfiles/blob/07c0c8df75b5077edab4258a93c91948b5ca719b/.vimrc#L715 And some extra project specific configuration on top: https://github.com/kmhofmann/selene/blob/062cb0a6a05a516a9b8d9a0cc3e779c181be3295/.lvimrc

rhysd commented 6 years ago

@kmhofmann Thank you for the info. It looks your configuration is more aggressive than mine (I only run linters/fixers on saving a buffer). So I think frequency of running linters/fixiers is high. This issue seems to occur when clever-f waits user input with getchar() and at the same moment ALE echoes some messages. So higher frequency of running linters would cause this issue more often.

Let me perform more investigation for this issue (actually I also feel this is annoying).

rhysd commented 5 years ago

I could also reproduce the error without clever-f.vim:

Error detected while processing function <SNR>184_VimCloseCallback[11]..<SNR>184_VimExitCallback[14]..<SNR>179_HandleExit[50]..ale#engine#Han
dleLoclist[33]..ale#engine#SetResults[26]..ale#cursor#EchoCursorWarning[22]..ale#cursor#TruncatedEcho:
line   15:
E523: Not allowed here
Error detected while processing function <SNR>184_VimCloseCallback:
line   11:
E171: Missing :endif

with mapping nnoremap <silent><expr>m 'i'.nr2char(getchar())."\<Esc>"

rhysd commented 5 years ago

This issue should be fixed by https://github.com/w0rp/ale/pull/1987. Please update ALE to the latest. If you still see this issue, please let me know by commenting here.

dagadbm commented 4 years ago

i dont use ale but i just got this error using coc. any way how i can fix this or notify maintainers of coc what the error actually is? i know 0 of vim script :(

dagadbm commented 4 years ago

its weird because im not even using clever f features.. im just doing delete til motions..