mirror of
https://github.com/vale981/tridactyl
synced 2025-03-06 10:01:39 -05:00
Remove try/catch in excmd completion
This commit removes the try/catch in the excmd completion source and instead makes the ExcmdCompletionOption constructor default to a string for missing values. This is useful for three reasons: - The try/catch discarded excmds that didn't have a type/documentation, but being able to autocomplete the name of these functions could still be useful - Try/catch are usually expensive - TypeScript wrongly complained about a missing parenthesis when the try/catch was there
This commit is contained in:
parent
e1bb76600e
commit
5eae45d0a0
1 changed files with 3 additions and 9 deletions
|
@ -7,8 +7,8 @@ class ExcmdCompletionOption extends Completions.CompletionOptionHTML
|
||||||
public fuseKeys = []
|
public fuseKeys = []
|
||||||
constructor(
|
constructor(
|
||||||
public value: string,
|
public value: string,
|
||||||
public ttype: string,
|
public ttype: string = "",
|
||||||
public documentation: string,
|
public documentation: string = "",
|
||||||
) {
|
) {
|
||||||
super()
|
super()
|
||||||
this.fuseKeys.push(this.value)
|
this.fuseKeys.push(this.value)
|
||||||
|
@ -49,13 +49,7 @@ export class ExcmdCompletionSource extends Completions.CompletionSourceFuse {
|
||||||
let fns = Metadata.everything["src/excmds.ts"]
|
let fns = Metadata.everything["src/excmds.ts"]
|
||||||
this.options = (await this.scoreOptions(
|
this.options = (await this.scoreOptions(
|
||||||
Object.keys(fns).filter(f => f.startsWith(exstr)),
|
Object.keys(fns).filter(f => f.startsWith(exstr)),
|
||||||
)).map(f => {
|
)).map(f => new ExcmdCompletionOption(f, fns[f].type, fns[f].doc))
|
||||||
try {
|
|
||||||
return new ExcmdCompletionOption(f, fns[f].type, fns[f].doc)
|
|
||||||
} catch {
|
|
||||||
return new ExcmdCompletionOption("", "", "")
|
|
||||||
}
|
|
||||||
})
|
|
||||||
this.options.forEach(o => (o.state = "normal"))
|
this.options.forEach(o => (o.state = "normal"))
|
||||||
this.updateChain()
|
this.updateChain()
|
||||||
}
|
}
|
||||||
|
|
Loading…
Add table
Reference in a new issue