diff options
Diffstat (limited to 'src/background/shared/completions/index.js')
-rw-r--r-- | src/background/shared/completions/index.js | 46 |
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([]); }; |