danchoi / ri.vim

browse ri documentation from Vim
http://github.com/danchoi/ri.vim
MIT License
114 stars 15 forks source link

Query string sent to 'ri_vim -d' doesn't comply with autocomplete result #22

Closed v-yadli closed 10 years ago

v-yadli commented 10 years ago

For example, if one type 'print' in the query window, 'ARGF#print' will be provided as an autocomplete entry. However, when enter key is hit, the query string remains to be 'print' and 'no matches!' is displayed, instead of the documentation of 'ARGF#print'.

danchoi commented 10 years ago

Please copy the lines from your :mes buffer.

You should see something like this after you do the steps above:

/Users/choi/p/ri.vim/plugin/ri_vim.rb 'print'
/Users/choi/p/ri.vim/plugin/ri_vim.rb -d 'ARGF#print'

If you see lines like this, try to execute the commands individually on the command line.

v-yadli commented 10 years ago

This is the interesting part. Instead of getting ri_vim -d 'ARGF#print', I get ri_vim -d 'print'.

related :mrs buffer content:

ri_vim 'print' ri_vim 'print' ri_vim -d 'print' No matches!

How did I produce these messages: Leader+r, bring up the search buffer; type 'print', then hit tab twice. Hit enter.

danchoi commented 10 years ago

Try putting some echom query debugging statements in the doSearch() function:

https://github.com/danchoi/ri.vim/blob/master/plugin/ri.vim#L234

Start at the bottom of the function and move upward with the debugging. You might see where the query string is being truncated or misread.

v-yadli commented 10 years ago

I think I know what happened now. In s:doSearch(), getline() is used to obtain the query line. So if the query line is 'print', it will search for 'print'.

The only problem is that auto completion is not so aggressive to replace the query string when it's not the prefix of a suggestion.

danchoi commented 10 years ago

Did you type 'print' and then press TAB first before you pressed ENTER? The TAB keystroke is necessary to autocomplete the module or class prefix for the method.

v-yadli commented 10 years ago

yes.

If I type 'IO#pri' then tab, it will autocomplete to 'IO#print'. (So the code logic is actually working)

However, if I type 'print' then tab, the query string remains to be 'print'. I guess it's a feature not a bug? :-)

danchoi commented 10 years ago

Strange that print doesn't TAB-autocomplete. Does the same thing happen for puts and delete?

v-yadli commented 10 years ago

The same thing. I noticed that there're two columns in the autocomplete entries. And the query string is completed to the first column, while the second is the actual full name.

danchoi commented 10 years ago

Can you screenshot what your autocomplete looks like? It should look something like this:

screen

v-yadli commented 10 years ago

After hitting tab, it looks like this:

screenshot

Note that it's different from your screenshot that the full name is not attached at the end. Just bare 'print'

danchoi commented 10 years ago

If you scroll down the completion matches with CTRL-n and then press ENTER, does it work?

v-yadli commented 10 years ago

No. Both failed.

On 5 Mar, 2014, at 10:39 am, Daniel Choi notifications@github.com wrote:

If you scroll down the completion matches with CTRL-n and then press ENTER, does it work?

— Reply to this email directly or view it on GitHub.

danchoi commented 10 years ago

Try using this new version at https://github.com/danchoi/ri.vim/blob/master/plugin/ri.vim

It may fix your problem, but I'm not sure if the fix has side effects yet.

v-yadli commented 10 years ago

Problem fixed. Now the full name is attached at the end. The side effect on my side is mainly about permissions. It might be due to that I directly replaced ri.vim in the gem directory (for that the plugin in .vim dir just source that one and I don't want to break this).

You might need to add

#!/usr/bin/ruby

on the first line of ri_vim.rb and then set execute permission to it. Also, my gem installation doesn't allow users to write ri_vim_cache directory. So I just chown'ed that.

Thanks for the help! :-)

danchoi commented 10 years ago

I'm glad it worked. If you're interested in helping maintain this project, let me know and I'll add you as admin.

v-yadli commented 10 years ago

I'm not really familiar with VimL and Ruby... Actually I'm doing a little project to learn ruby. I'll fork this project and in case there's something I could help, I will send you a pull request. :-)

wikimatze commented 10 years ago

@v-yadli the issue you reported is not there anymore, I will close this issue.