aboutsummaryrefslogtreecommitdiff
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2020-03-28 21:48:30 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2020-03-28 21:48:30 +0900
commitdf82fac78fbc2541fcd60a6daf0ccbb7809260d1 (patch)
tree97d3133372a6f799de850266fa9700d29a3d5cca
parentea63c5f78b4c985e9d6dd106afe4f97bfeedbcd0 (diff)
Skip group on completion completions
-rw-r--r--src/console/actions/console.ts73
1 files changed, 44 insertions, 29 deletions
diff --git a/src/console/actions/console.ts b/src/console/actions/console.ts
index 603a98d..89d9c3c 100644
--- a/src/console/actions/console.ts
+++ b/src/console/actions/console.ts
@@ -114,38 +114,50 @@ const getOpenCompletions = async(
const completions: Completions = [];
for (const type of types) {
switch (type) {
- case CompletionType.SearchEngines:
+ case CompletionType.SearchEngines: {
+ const items = await completionClient.requestSearchEngines(query);
+ if (items.length === 0) {
+ break;
+ }
completions.push({
name: 'Search Engines',
- items: (await completionClient.requestSearchEngines(query))
- .map(key => ({
- caption: key.title,
- content: command + ' ' + key.title,
- }))
+ items: items.map(key => ({
+ caption: key.title,
+ content: command + ' ' + key.title,
+ }))
});
break;
- case CompletionType.History:
+ }
+ case CompletionType.History: {
+ const items = await completionClient.requestHistory(query);
+ if (items.length === 0) {
+ break;
+ }
completions.push({
name: 'History',
- items: (await completionClient.requestHistory(query))
- .map(item => ({
- caption: item.title,
- content: command + ' ' + item.url,
- url: item.url
- })),
+ items: items.map(item => ({
+ caption: item.title,
+ content: command + ' ' + item.url,
+ url: item.url
+ })),
});
break;
- case CompletionType.Bookmarks:
+ }
+ case CompletionType.Bookmarks: {
+ const items = await completionClient.requestBookmarks(query);
+ if (items.length === 0) {
+ break;
+ }
completions.push({
name: 'Bookmarks',
- items: (await completionClient.requestBookmarks(query))
- .map(item => ({
- caption: item.title,
- content: command + ' ' + item.url,
- url: item.url
- }))
+ items: items.map(item => ({
+ caption: item.title,
+ content: command + ' ' + item.url,
+ url: item.url
+ }))
});
break;
+ }
}
}
@@ -160,15 +172,18 @@ const getTabCompletions = async (
original: string, command: Command, query: string, excludePinned: boolean,
): Promise<actions.SetCompletionsAction> => {
const items = await completionClient.requestTabs(query, excludePinned);
- const completions = [{
- name: 'Buffers',
- items: items.map(item => ({
- content: command + ' ' + item.url,
- caption: `${item.index}: ${item.flag != TabFlag.None ? item.flag : ' ' } ${item.title}`,
- url: item.url,
- icon: item.faviconUrl,
- })),
- }];
+ let completions: Completions = [];
+ if (items.length > 0) {
+ completions = [{
+ name: 'Buffers',
+ items: items.map(item => ({
+ content: command + ' ' + item.url,
+ caption: `${item.index}: ${item.flag != TabFlag.None ? item.flag : ' ' } ${item.title}`,
+ url: item.url,
+ icon: item.faviconUrl,
+ })),
+ }];
+ }
return {
type: actions.CONSOLE_SET_COMPLETIONS,
completions,