Add complete property

jh-changes
Shin'ya Ueoka 6 years ago
parent 1b77846382
commit bab8066af8
  1. 33
      src/background/usecases/completions.js
  2. 3
      src/shared/settings/default.js
  3. 3
      src/shared/settings/properties.js

@ -36,18 +36,29 @@ export default class CompletionsInteractor {
} }
async queryOpen(name, keywords) { async queryOpen(name, keywords) {
let settings = await this.settingRepository.get();
let groups = []; let groups = [];
let engines = await this.querySearchEngineItems(name, keywords);
if (engines.length > 0) { for (let c of settings.properties.complete) {
groups.push(new CompletionGroup('Search Engines', engines)); if (c === 's') {
} // eslint-disable-next-line no-await-in-loop
let histories = await this.queryHistoryItems(name, keywords); let engines = await this.querySearchEngineItems(name, keywords);
if (histories.length > 0) { if (engines.length > 0) {
groups.push(new CompletionGroup('History', histories)); groups.push(new CompletionGroup('Search Engines', engines));
} }
let bookmarks = await this.queryBookmarkItems(name, keywords); } else if (c === 'h') {
if (bookmarks.length > 0) { // eslint-disable-next-line no-await-in-loop
groups.push(new CompletionGroup('Bookmarks', bookmarks)); let histories = await this.queryHistoryItems(name, keywords);
if (histories.length > 0) {
groups.push(new CompletionGroup('History', histories));
}
} else if (c === 'b') {
// eslint-disable-next-line no-await-in-loop
let bookmarks = await this.queryBookmarkItems(name, keywords);
if (bookmarks.length > 0) {
groups.push(new CompletionGroup('Bookmarks', bookmarks));
}
}
} }
return new Completions(groups); return new Completions(groups);
} }

@ -72,7 +72,8 @@ export default {
"properties": { "properties": {
"hintchars": "abcdefghijklmnopqrstuvwxyz", "hintchars": "abcdefghijklmnopqrstuvwxyz",
"smoothscroll": false, "smoothscroll": false,
"adjacenttab": true "adjacenttab": true,
"complete": "sbh"
}, },
"blacklist": [ "blacklist": [
] ]

@ -6,6 +6,7 @@ const types = {
hintchars: 'string', hintchars: 'string',
smoothscroll: 'boolean', smoothscroll: 'boolean',
adjacenttab: 'boolean', adjacenttab: 'boolean',
complete: 'string',
}; };
// describe default values of a property // describe default values of a property
@ -13,12 +14,14 @@ const defaults = {
hintchars: 'abcdefghijklmnopqrstuvwxyz', hintchars: 'abcdefghijklmnopqrstuvwxyz',
smoothscroll: false, smoothscroll: false,
adjacenttab: true, adjacenttab: true,
complete: 'sbn',
}; };
const docs = { const docs = {
hintchars: 'hint characters on follow mode', hintchars: 'hint characters on follow mode',
smoothscroll: 'smooth scroll', smoothscroll: 'smooth scroll',
adjacenttab: 'open adjacent tabs', adjacenttab: 'open adjacent tabs',
complete: 'which are completed at the open page',
}; };
export { types, defaults, docs }; export { types, defaults, docs };