Ron89 / thesaurus_query.vim

Multi-language Thesaurus Query and Replacement plugin for Vim/NeoVim
http://www.vim.org/scripts/script.php?script_id=5341
Apache License 2.0
220 stars 23 forks source link

Buffer with this name already exists #29

Closed elig0n closed 6 years ago

elig0n commented 6 years ago

after closing a Thesaurus query window with 'q' trying to run the query again for the same word results in

Error detected while processing function thesaurus_query#Thesaurus_Query_Lookup: line 49: Traceback (most recent call last): File "", line 1, in File "/home/eligon/.vim/bundle/thesaurus_query.vim/autoload/thesaurus_query/thesaurus_query.py", line 380, in tq_generate_thesaurus_buffer vim_command('exec ":silent file thesaurus:\\ " . l:word_fname . "\\ (press\\ q\\ to\\ close\\ this\\ split.)"') File "/home/eligon/.vim/bundle/thesaurus_query.vim/autoload/thesaurus_query/tq_common_lib.py", line 120, in vim_command vim.command(command) vim.error: Vim(file):E95: Buffer with this name already exists

Ron89 commented 6 years ago

It's strange. I managed to reproduce your issue on one instance, when bufwinnr output was behaving weird. But then after opening Vim in a different instance where bufwinnr is behaving as expected, I can no longer reproduce it.

Could you attach your environment? Like Vim version, and OS type? I have tried on both Mac and CentOS Linux 64bit.

Ron89 commented 6 years ago

@deathmaz , did you managed to reproduce his issue?

deathmaz commented 6 years ago

Yes i did, i'm using NVIM v0.2.2 on Manjaro Linux 17.1.10 Hakoila

elig0n commented 6 years ago

VIM - Vi IMproved 7.4 (2013 Aug 10, compiled Nov 24 2016 16:44:48)
Included patches: 1-1689
Extra patches: 8.0.0056

On Bash on Ubuntu (WSL ).

Ron89 commented 6 years ago

Hi all, please try out the test branch to see if the issue is addressed. I have made some change and committed it to test branch. It should address the issue, but since I still couldn't reproduce it, I have to rely on your feedback before merge it to master branch.

From the error message itself, also my earlier experience in reproducing of the issue, it looks like error is triggered at line 380 of autoload/thesaurus_query/thesaurus_query.py. This looks like the plugin failed to find the thesaurus buffer using pattern "^thesaurus: ", hence creating a new window, and then try to rename that new window to a name coincide with the original thesaurus buffer, triggering the "E95" issue.

The solution here is to avoid renaming a wrong buffer by try to entering the existing buffer in line 379 (commited file line 380). In this command, Vim shall split to the buffer with the target name, and only rename current buffer if the buffer do not exist. Actually I believe this is the originally intended logic. But I might have made a mistake modifying it some time ago.

Still, please try it out in test branch, in the plugin repo:

git fetch origin
git checkout testing

then try out the operation. If issue doesn't happen any more, let me know, then revert back to master branch, wait for me to merge. Thanks.

deathmaz commented 6 years ago

Works perfectly fine on my end

Ron89 commented 6 years ago

Issue fixed on commit 859ee01.