Home Download Buy Blog Forum Support

Cyclic autocomplete suggestions

Cyclic autocomplete suggestions

Postby Alvaro on Wed Dec 05, 2012 10:56 am

Is it possible to loop through the autocomplete suggestion in a cyclic way, so if you reach the bottom, you are automatically moved up to the first suggestion?
Im writing a plugin that heavily uses autocomplete suggestions and I find that feature very handy.

Thanks
Alvaro
 
Posts: 9
Joined: Wed Dec 05, 2012 10:49 am

Re: Cyclic autocomplete suggestions

Postby agibsonsw on Wed Dec 05, 2012 8:03 pm

I use the following set of key-bindings to enable me to use Ctrl-Alt-Left and Ctrl-Alt-Right to cycle through the completions. It is not moving up and down the displayed completions list, but it does cycle back to the top (or bottom).

Code: Select all
[
   { "keys": ["ctrl+alt+right"], "command": "insert_best_completion", "args": {"default": "", "exact": true} },
   { "keys": ["ctrl+alt+right"], "command": "insert_best_completion", "args": {"default": "", "exact": false},
      "context":
      [
         { "key": "setting.tab_completion", "operator": "equal", "operand": true }
      ]
   },
   { "keys": ["ctrl+alt+right"], "command": "replace_completion_with_next_completion", "context":
      [
         { "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
         { "key": "setting.tab_completion", "operator": "equal", "operand": true }
      ]
   },
   { "keys": ["ctrl+alt+left"], "command": "replace_completion_with_prev_completion", "context":
      [
         { "key": "last_command", "operator": "equal", "operand": "insert_best_completion" },
         { "key": "setting.tab_completion", "operator": "equal", "operand": true }
      ]
   }

Also,it will break if there is an odd (word-ending) character in one of the completions.

I do not know if this is possible with the visible completions-list (but have doubts..).
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm

Re: Cyclic autocomplete suggestions

Postby Alvaro on Sat Dec 08, 2012 1:28 pm

Thanks! Thats a great idea and trick, but unfortunately its not was I was looking found since I have many completitions candidates and I would prefer to use the dropdown menu to look for the right one.
Alvaro
 
Posts: 9
Joined: Wed Dec 05, 2012 10:49 am

Re: Cyclic autocomplete suggestions

Postby agibsonsw on Sat Dec 08, 2012 7:36 pm

Alvaro wrote:Thanks! Thats a great idea and trick, but unfortunately its not was I was looking found since I have many completitions candidates and I would prefer to use the dropdown menu to look for the right one.

I personally don't know if you are able to do anything with the ui-completions-list itself, other than up, down, esc, tab or enter. The question arises as to why you have so many similar completions, and doesn't fuzzy-seach overcome this. If you are writing a plug-in then you might use on_query_completions to cut down the number of items listed. But I assume you've already considered these points ;) .
"I'm here to save your life. But if I'm going to do that, I'll need total uninanonynymity." Me Myself & Irene.
agibsonsw
 
Posts: 901
Joined: Fri Jan 27, 2012 9:11 pm


Return to Ideas and Feature Requests

Who is online

Users browsing this forum: Google [Bot], Yahoo [Bot] and 10 guests