Skip to content

Commit ac55e0d

Browse files
committed
refactor to async/wait
1 parent e1054b7 commit ac55e0d

File tree

1 file changed

+10
-10
lines changed

1 file changed

+10
-10
lines changed

src/browser/pages/vscode.ts

+10-10
Original file line numberDiff line numberDiff line change
@@ -72,22 +72,22 @@ export function getNlsConfiguration(_document: Document, base: string) {
7272

7373
type LoadBundleCallback = (_: undefined, result?: string) => void
7474

75-
nlsConfig.loadBundle = (bundle: string, _language: string, cb: LoadBundleCallback): void => {
75+
nlsConfig.loadBundle = async (bundle: string, _language: string, cb: LoadBundleCallback): Promise<void> => {
7676
// TODO@jsjoeio write tests for here to END
7777
const result = bundles[bundle]
7878
if (result) {
7979
return cb(undefined, result)
8080
}
8181
// FIXME: Only works if path separators are /.
82-
const path = createBundlePath(nlsConfig._resolvedLanguagePackCoreLocation || "", bundle)
83-
fetch(`${base}/vscode/resource/?path=${encodeURIComponent(path)}`)
84-
.then((response) => response.json())
85-
.then((json) => {
86-
bundles[bundle] = json
87-
cb(undefined, json)
88-
// END here
89-
})
90-
.catch(cb)
82+
try {
83+
const path = createBundlePath(nlsConfig._resolvedLanguagePackCoreLocation || "", bundle)
84+
const response = await fetch(`${base}/vscode/resource/?path=${encodeURIComponent(path)}`)
85+
const json = await response.json()
86+
bundles[bundle] = json
87+
return cb(undefined, json)
88+
} catch (error) {
89+
return cb(error)
90+
}
9191
}
9292
}
9393

0 commit comments

Comments
 (0)