Skip to content

Commit 443e45a

Browse files
authored
Merge pull request #22 from CodinGame/fix-missing-polyfill
Add missing polyfills
2 parents ca44f3d + 6485cc7 commit 443e45a

2 files changed

Lines changed: 19 additions & 5 deletions

File tree

src/polyfill.ts

Lines changed: 18 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -13,8 +13,25 @@ import { getSingletonServiceDescriptors } from 'vs/platform/instantiation/common
1313
import { ILabelService } from 'vs/platform/label/common/label'
1414
import { Event } from 'vs/base/common/event'
1515
import { IQuickInput, IQuickPick } from 'vs/base/parts/quickinput/common/quickInput'
16+
// @ts-ignore Creating a d.ts is not worth it
17+
import { LanguageService as MonacoLanguageService } from 'monaco-editor/esm/vs/editor/common/services/languageService.js'
18+
import { LanguageService as VScodeLanguageService } from 'vscode/vs/editor/common/services/languageService.js'
19+
// @ts-ignore Creating a d.ts is not worth it
20+
import { NoOpNotification as MonacoNoOpNotification } from 'monaco-editor/esm/vs/platform/notification/common/notification.js'
21+
import { NoOpNotification as VScodeNoOpNotification } from 'vscode/vs/platform/notification/common/notification.js'
22+
23+
// @ts-ignore Override of a readonly property
24+
MonacoNoOpNotification.prototype.onDidClose ??= Event.None
25+
for (const key of Object.getOwnPropertyNames(VScodeNoOpNotification.prototype)) {
26+
if (!Object.hasOwnProperty.call(MonacoNoOpNotification.prototype, key)) {
27+
// eslint-disable-next-line @typescript-eslint/no-explicit-any
28+
MonacoNoOpNotification.prototype[key] = (VScodeNoOpNotification.prototype as any)[key]
29+
}
30+
}
31+
32+
MonacoLanguageService.prototype.getRegisteredLanguageIds ??= VScodeLanguageService.prototype.getRegisteredLanguageIds;
1633

17-
(MonacoProgressBar as typeof VScodeProgressBar).prototype.hide = VScodeProgressBar.prototype.hide
34+
(MonacoProgressBar as typeof VScodeProgressBar).prototype.hide ??= VScodeProgressBar.prototype.hide
1835

1936
// eslint-disable-next-line dot-notation
2037
;(MonacoThemable as typeof VScodeThemable).prototype['getColor'] ??= VScodeThemable.prototype['getColor']

src/services.ts

Lines changed: 1 addition & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -34,10 +34,7 @@ let services: Services | undefined
3434
export namespace Services {
3535
export type Provider = () => Services
3636
export const get: Provider = () => {
37-
if (services == null) {
38-
throw new Error('Services has not been installed')
39-
}
40-
return services
37+
return services ?? {}
4138
}
4239
export function install (_services: Services): vscode.Disposable {
4340
if (services != null) {

0 commit comments

Comments
 (0)