beloglazov/vim-online-thesaurus

E94: No matching buffer for ^thesaurus$

Closed this issue · 4 comments

When I run :OnlineThesaurusCurrentWord I get this error message:

Error detected while processing function <SNR>19_Lookup:
line    1:
E94: No matching buffer for ^thesaurus$

To reproduce the bug, you have to put in your vimrc:

set debug=msg,throw

I think that this is a Vim bug because the function bufwinnr() should return -1 without error if the buffer does not exist, but you can avoid it with the following code:

    if bufexists('^thesaurus$')
        let l:thesaurus_window = bufwinnr('^thesaurus$')
    else
        let l:thesaurus_window = -1
    endif

Weird.
There is a test that checks whether the value is above -1. Silly me believed the documentation.
Can you open a PR replacing the old if with yours? (no need for the local variable in this case either).

Don't know why it throws the error, because the return values are correct.
Thanks for the bug!

EDIT:
I tested this solution and read a bit of documentation and it doesn't really solve the issue.
bufexists() returns 1 after the thesaurus window has opened once, even if it is closed.

May I ask why are you setting these debug options in your normal work?

EDIT2:
I've found a working solution.
I will open a PR soon.
Thanks again!

Sorry, I did see your edits your comment above. Please, ignore my PR and go ahead fixing the issue.

I guess you only read the email. I should have probably write the updates in a new comment so you would get them by email too.

I really appreciate you took the time making the PR 👍
You can take a look at mine (#26).

Fixed in #26