Skip to content

Commit faf0af2

Browse files
committed
Use async/await for onCompletionResolve
1 parent bafb016 commit faf0af2

File tree

1 file changed

+18
-16
lines changed

1 file changed

+18
-16
lines changed

server/src/server.ts

+18-16
Original file line numberDiff line numberDiff line change
@@ -172,26 +172,28 @@ export default class BashServer {
172172
return [...symbolCompletions, ...programCompletions, ...builtinsCompletions]
173173
}
174174

175-
private onCompletionResolve(item: LSP.CompletionItem): Promise<LSP.CompletionItem> {
176-
// TODO: async await would be nice I guess
177-
if (item.data.type === 'executable') {
178-
return this.executables
179-
.documentation(item.data.name)
180-
.then(doc => ({
175+
private async onCompletionResolve(
176+
item: LSP.CompletionItem,
177+
): Promise<LSP.CompletionItem> {
178+
const { data: { name, type } } = item
179+
try {
180+
if (type === 'executable') {
181+
const doc = await this.executables.documentation(name)
182+
return {
181183
...item,
182184
detail: doc,
183-
}))
184-
.catch(() => item)
185-
} else if (item.data.type === 'builtin') {
186-
//
187-
return Builtins.documentation(item.data.name)
188-
.then(doc => ({
185+
}
186+
} else if (type === 'builtin') {
187+
const doc = await Builtins.documentation(name)
188+
return {
189189
...item,
190190
detail: doc,
191-
}))
192-
.catch(() => item)
193-
} else {
194-
return Promise.resolve(item)
191+
}
192+
} else {
193+
return item
194+
}
195+
} catch (error) {
196+
return item
195197
}
196198
}
197199
}

0 commit comments

Comments
 (0)