Fix "tab" alias breaking completions

PR#1183 broke completions for users that had a tab -> buffer alias. This
is because having such an alias created a loop, which made
BufferCompletionSource throw errors when being instanciated, which
resulted in the activeCompletions array not being created.

This is fixed in two ways: first, a config updater is created in order
to remove the alias. Second, completions are instantiated in
try/catchs, which should hopefully prevent a faulty completion source
constructor from breaking every completion source.
This commit is contained in:
glacambre 2018-12-10 07:00:11 +01:00
parent 2e0774df79
commit 4a6305df47
No known key found for this signature in database
GPG key ID: B9625DB1767553AC
2 changed files with 19 additions and 9 deletions

View file

@ -92,16 +92,22 @@ function getCompletion() {
export function enableCompletions() {
if (!activeCompletions) {
activeCompletions = [
new BmarkCompletionSource(completionsDiv),
new TabAllCompletionSource(completionsDiv),
new BufferCompletionSource(completionsDiv),
new ExcmdCompletionSource(completionsDiv),
new FileSystemCompletionSource(completionsDiv),
new HelpCompletionSource(completionsDiv),
new HistoryCompletionSource(completionsDiv),
new PreferenceCompletionSource(completionsDiv),
new SettingsCompletionSource(completionsDiv),
BmarkCompletionSource,
TabAllCompletionSource,
BufferCompletionSource,
ExcmdCompletionSource,
FileSystemCompletionSource,
HelpCompletionSource,
HistoryCompletionSource,
PreferenceCompletionSource,
SettingsCompletionSource,
]
.map(constructorr => {
try {
return new constructorr(completionsDiv)
} catch (e) {}
})
.filter(c => c)
const fragment = document.createDocumentFragment()
activeCompletions.forEach(comp => fragment.appendChild(comp.node))

View file

@ -1078,6 +1078,10 @@ export async function update() {
)
set("configversion", "1.5")
},
"1.5": () => {
unset("exaliases", "tab")
set("configversion", "1.6")
},
}
if (!get("configversion")) set("configversion", "0.0")
const updatetest = v => {