|
|
@ -1,7 +1,19 @@ |
|
|
|
|
|
|
|
import commandDocs from 'shared/commands/docs'; |
|
|
|
import * as tabs from './tabs'; |
|
|
|
import * as tabs from './tabs'; |
|
|
|
import * as histories from './histories'; |
|
|
|
import * as histories from './histories'; |
|
|
|
import * as bookmarks from './bookmarks'; |
|
|
|
import * as bookmarks from './bookmarks'; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
const completeCommands = (typing) => { |
|
|
|
|
|
|
|
let keys = Object.keys(commandDocs); |
|
|
|
|
|
|
|
return keys |
|
|
|
|
|
|
|
.filter(name => name.startsWith(typing)) |
|
|
|
|
|
|
|
.map(name => ({ |
|
|
|
|
|
|
|
caption: name, |
|
|
|
|
|
|
|
content: name, |
|
|
|
|
|
|
|
url: commandDocs[name], |
|
|
|
|
|
|
|
})); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const getSearchCompletions = (command, keywords, searchConfig) => { |
|
|
|
const getSearchCompletions = (command, keywords, searchConfig) => { |
|
|
|
let engineNames = Object.keys(searchConfig.engines); |
|
|
|
let engineNames = Object.keys(searchConfig.engines); |
|
|
|
let engineItems = engineNames.filter(name => name.startsWith(keywords)) |
|
|
|
let engineItems = engineNames.filter(name => name.startsWith(keywords)) |
|
|
@ -74,20 +86,21 @@ const getBufferCompletions = async(command, keywords, excludePinned) => { |
|
|
|
]; |
|
|
|
]; |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const getCompletions = (line, settings) => { |
|
|
|
const complete = (line, settings) => { |
|
|
|
let typedWords = line.trim().split(/ +/); |
|
|
|
let trimmed = line.trimStart(); |
|
|
|
let typing = ''; |
|
|
|
let words = trimmed.split(/ +/); |
|
|
|
if (!line.endsWith(' ')) { |
|
|
|
let name = words[0]; |
|
|
|
typing = typedWords.pop(); |
|
|
|
if (words.length === 1) { |
|
|
|
|
|
|
|
return Promise.resolve([ |
|
|
|
|
|
|
|
{ |
|
|
|
|
|
|
|
name: 'Console Command', |
|
|
|
|
|
|
|
items: completeCommands(name), |
|
|
|
} |
|
|
|
} |
|
|
|
|
|
|
|
]); |
|
|
|
if (typedWords.length === 0) { |
|
|
|
|
|
|
|
return Promise.resolve([]); |
|
|
|
|
|
|
|
} |
|
|
|
} |
|
|
|
let name = typedWords.shift(); |
|
|
|
let keywords = trimmed.slice(name.length).trimStart(); |
|
|
|
let keywords = typedWords.concat(typing).join(' '); |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
switch (name) { |
|
|
|
switch (words[0]) { |
|
|
|
case 'o': |
|
|
|
case 'o': |
|
|
|
case 'open': |
|
|
|
case 'open': |
|
|
|
case 't': |
|
|
|
case 't': |
|
|
@ -112,8 +125,4 @@ const getCompletions = (line, settings) => { |
|
|
|
return Promise.resolve([]); |
|
|
|
return Promise.resolve([]); |
|
|
|
}; |
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
const complete = (line, settings) => { |
|
|
|
|
|
|
|
return getCompletions(line, settings); |
|
|
|
|
|
|
|
}; |
|
|
|
|
|
|
|
|
|
|
|
|
|
|
|
export { complete }; |
|
|
|
export { complete }; |
|
|
|