aboutsummaryrefslogtreecommitdiff
path: root/src/background/shared/completions/index.js
diff options
context:
space:
mode:
authorShin'ya Ueoka <ueokande@i-beam.org>2018-05-12 16:28:43 +0900
committerGitHub <noreply@github.com>2018-05-12 16:28:43 +0900
commitc6c885345e212bedc2723e9105488d3e5fe9f8be (patch)
treebeaca04a06f6f02f9222af0e73b3768f994f6acd /src/background/shared/completions/index.js
parentb0dddc9fa7765dc252fd11fc7d0fe52820655fd5 (diff)
parenta8ac7415f8b5e9e9dc36318a04b7da7775796a88 (diff)
Merge pull request #391 from ueokande/delete-tabs
Delete tabs
Diffstat (limited to 'src/background/shared/completions/index.js')
-rw-r--r--src/background/shared/completions/index.js46
1 files changed, 30 insertions, 16 deletions
diff --git a/src/background/shared/completions/index.js b/src/background/shared/completions/index.js
index 8ecdcfc..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,22 +107,17 @@ const getCompletions = (line, settings) => {
return getOpenCompletions(name, keywords, settings.search);
case 'b':
case 'buffer':
- 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, false);
+ case 'bd':
+ case 'bdel':
+ case 'bdelete':
+ case 'bdeletes':
+ return getBufferCompletions(name, keywords, true);
}
return Promise.resolve([]);
};