completion in background
This commit is contained in:
		
							parent
							
								
									40cc5b9175
								
							
						
					
					
						commit
						749eea5ecf
					
				
					 2 changed files with 11 additions and 10 deletions
				
			
		|  | @ -63,12 +63,12 @@ const bufferCommand = (keywords) => { | ||||||
|   }); |   }); | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const getOpenCompletions = (keywords) => { | const getOpenCompletions = (command, keywords) => { | ||||||
|   return histories.getCompletions(keywords).then((pages) => { |   return histories.getCompletions(keywords).then((pages) => { | ||||||
|     let historyItems = pages.map((page) => { |     let historyItems = pages.map((page) => { | ||||||
|       return { |       return { | ||||||
|         caption: page.title, |         caption: page.title, | ||||||
|         content: page.url, |         content: command + ' ' + page.url, | ||||||
|         url: page.url |         url: page.url | ||||||
|       }; |       }; | ||||||
|     }); |     }); | ||||||
|  | @ -76,7 +76,7 @@ const getOpenCompletions = (keywords) => { | ||||||
|     let engineItems = engineNames.filter(name => name.startsWith(keywords)) |     let engineItems = engineNames.filter(name => name.startsWith(keywords)) | ||||||
|       .map(name => ({ |       .map(name => ({ | ||||||
|         caption: name, |         caption: name, | ||||||
|         content: name |         content: command + ' ' + name | ||||||
|       })); |       })); | ||||||
| 
 | 
 | ||||||
|     let completions = []; |     let completions = []; | ||||||
|  | @ -118,14 +118,14 @@ const getCompletions = (command, keywords) => { | ||||||
|   case 'open': |   case 'open': | ||||||
|   case 't': |   case 't': | ||||||
|   case 'tabopen': |   case 'tabopen': | ||||||
|     return getOpenCompletions(keywords); |     return getOpenCompletions(command, keywords); | ||||||
|   case 'b': |   case 'b': | ||||||
|   case 'buffer': |   case 'buffer': | ||||||
|     return tabs.getCompletions(keywords).then((gotTabs) => { |     return tabs.getCompletions(keywords).then((gotTabs) => { | ||||||
|       let items = gotTabs.map((tab) => { |       let items = gotTabs.map((tab) => { | ||||||
|         return { |         return { | ||||||
|           caption: tab.title, |           caption: tab.title, | ||||||
|           content: tab.title, |           content: command + ' ' + tab.title, | ||||||
|           url: tab.url, |           url: tab.url, | ||||||
|           icon: tab.favIconUrl |           icon: tab.favIconUrl | ||||||
|         }; |         }; | ||||||
|  |  | ||||||
|  | @ -26,9 +26,9 @@ completionStore.subscribe(() => { | ||||||
| 
 | 
 | ||||||
|   if (state.groupSelection >= 0) { |   if (state.groupSelection >= 0) { | ||||||
|     let item = state.groups[state.groupSelection].items[state.itemSelection]; |     let item = state.groups[state.groupSelection].items[state.itemSelection]; | ||||||
|     input.value = completionOrigin + ' ' + item.content; |     input.value = item.content; | ||||||
|   } else if (state.groups.length > 0) { |   } else if (state.groups.length > 0) { | ||||||
|     input.value = completionOrigin + ' '; |     input.value = completionOrigin; | ||||||
|   } |   } | ||||||
| }); | }); | ||||||
| 
 | 
 | ||||||
|  | @ -68,6 +68,10 @@ const handleKeyup = (e) => { | ||||||
|   if (e.target.value === prevValue) { |   if (e.target.value === prevValue) { | ||||||
|     return; |     return; | ||||||
|   } |   } | ||||||
|  | 
 | ||||||
|  |   let input = window.document.querySelector('#vimvixen-console-command-input'); | ||||||
|  |   completionOrigin = input.value; | ||||||
|  | 
 | ||||||
|   prevValue = e.target.value; |   prevValue = e.target.value; | ||||||
|   return browser.runtime.sendMessage({ |   return browser.runtime.sendMessage({ | ||||||
|     type: messages.CONSOLE_CHANGEED, |     type: messages.CONSOLE_CHANGEED, | ||||||
|  | @ -84,9 +88,6 @@ window.addEventListener('load', () => { | ||||||
| 
 | 
 | ||||||
| const updateCompletions = (completions) => { | const updateCompletions = (completions) => { | ||||||
|   completionStore.dispatch(completionActions.setItems(completions)); |   completionStore.dispatch(completionActions.setItems(completions)); | ||||||
| 
 |  | ||||||
|   let input = window.document.querySelector('#vimvixen-console-command-input'); |  | ||||||
|   completionOrigin = input.value.split(' ')[0]; |  | ||||||
| }; | }; | ||||||
| 
 | 
 | ||||||
| const update = (state) => { | const update = (state) => { | ||||||
|  |  | ||||||
		Reference in a new issue