aboutsummaryrefslogtreecommitdiff
path: root/src/background/shared/completions/index.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-05-12 09:47:21 +0900
committerShin'ya Ueoka <ueokande@i-beam.org>2018-05-12 10:54:38 +0900
commita8ac7415f8b5e9e9dc36318a04b7da7775796a88 (patch)
treebeaca04a06f6f02f9222af0e73b3768f994f6acd /src/background/shared/completions/index.js
parent4116d0864213e30a6157edb6e573b0c880a4ec66 (diff)
Fix tab completions
Diffstat (limited to 'src/background/shared/completions/index.js')
-rw-r--r--src/background/shared/completions/index.js46
1 files changed, 26 insertions, 20 deletions
diff --git a/src/background/shared/completions/index.js b/src/background/shared/completions/index.js
index 21c3dd2..728cee7 100644
--- a/src/background/shared/completions/index.js
+++ b/src/background/shared/completions/index.js
@@ -65,6 +65,25 @@ const getOpenCompletions = (command, keywords, searchConfig) => {
});
};
+const getBufferCompletions = (command, keywords, excludePinned) => {
+ return tabs.getCompletions(keywords, excludePinned).then((got) => {
+ let items = got.map((tab) => {
+ return {
+ caption: tab.title,
+ content: command + ' ' + tab.title,
+ url: tab.url,
+ icon: tab.favIconUrl
+ };
+ });
+ return [
+ {
+ name: 'Buffers',
+ items: items
+ }
+ ];
+ });
+};
+
const getCompletions = (line, settings) => {
let typedWords = line.trim().split(/ +/);
let typing = '';
@@ -88,30 +107,17 @@ const getCompletions = (line, settings) => {
return getOpenCompletions(name, keywords, settings.search);
case 'b':
case 'buffer':
- case 'bd':
- case 'bdel':
- case 'bdelete':
+ return getBufferCompletions(name, keywords, false);
case 'bd!':
case 'bdel!':
case 'bdelete!':
- case 'bdeletes':
case 'bdeletes!':
- return tabs.getCompletions(keywords).then((gotTabs) => {
- let items = gotTabs.map((tab) => {
- return {
- caption: tab.title,
- content: name + ' ' + tab.title,
- url: tab.url,
- icon: tab.favIconUrl
- };
- });
- return [
- {
- name: 'Buffers',
- items: items
- }
- ];
- });
+ return getBufferCompletions(name, keywords, false);
+ case 'bd':
+ case 'bdel':
+ case 'bdelete':
+ case 'bdeletes':
+ return getBufferCompletions(name, keywords, true);
}
return Promise.resolve([]);
};