Fix tab completions
This commit is contained in:
parent
4116d08642
commit
a8ac7415f8
4 changed files with 31 additions and 25 deletions
|
@ -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([]);
|
||||
};
|
||||
|
|
Reference in a new issue