forked from DonJayamanne/pythonVSCode
-
Notifications
You must be signed in to change notification settings - Fork 1.3k
Expand file tree
/
Copy pathsurceMapSupportService.ts
More file actions
46 lines (43 loc) · 1.88 KB
/
surceMapSupportService.ts
File metadata and controls
46 lines (43 loc) · 1.88 KB
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
// Copyright (c) Microsoft Corporation. All rights reserved.
// Licensed under the MIT License.
'use strict';
import { inject, injectable } from 'inversify';
import { ConfigurationTarget } from 'vscode';
import { IApplicationShell, ICommandManager } from '../../common/application/types';
import { Commands } from '../../common/constants';
import { IConfigurationService, IDisposableRegistry } from '../../common/types';
import { Diagnostics } from '../../common/utils/localize';
import { ISourceMapSupportService } from './types';
@injectable()
export class SourceMapSupportService implements ISourceMapSupportService {
constructor(
@inject(ICommandManager) private readonly commandManager: ICommandManager,
@inject(IDisposableRegistry) private readonly disposables: IDisposableRegistry,
@inject(IConfigurationService) private readonly configurationService: IConfigurationService,
@inject(IApplicationShell) private readonly shell: IApplicationShell,
) {}
public register(): void {
this.disposables.push(
this.commandManager.registerCommand(Commands.Enable_SourceMap_Support, this.onEnable, this),
);
}
public async enable(): Promise<void> {
await this.configurationService.updateSetting(
'diagnostics.sourceMapsEnabled',
true,
undefined,
ConfigurationTarget.Global,
);
await this.commandManager.executeCommand('workbench.action.reloadWindow');
}
protected async onEnable(): Promise<void> {
const enableSourceMapsAndReloadVSC = Diagnostics.enableSourceMapsAndReloadVSC;
const selection = await this.shell.showWarningMessage(
Diagnostics.warnBeforeEnablingSourceMaps,
enableSourceMapsAndReloadVSC,
);
if (selection === enableSourceMapsAndReloadVSC) {
await this.enable();
}
}
}