@codingame/monaco-vscode-output-service-override 3.2.2 → 4.0.0

This diff represents the content of publicly available package versions that have been released to one of the supported registries. The information contained in this diff is provided for informational purposes only and reflects changes between package versions as they appear in their respective public registries.
package/package.json CHANGED
@@ -1,6 +1,6 @@
1
1
  {
2
2
  "name": "@codingame/monaco-vscode-output-service-override",
3
- "version": "3.2.2",
3
+ "version": "4.0.0",
4
4
  "keywords": [],
5
5
  "author": {
6
6
  "name": "CodinGame",
@@ -18,8 +18,8 @@
18
18
  "module": "index.js",
19
19
  "types": "index.d.ts",
20
20
  "dependencies": {
21
- "vscode": "npm:@codingame/monaco-vscode-api@3.2.2",
22
- "@codingame/monaco-vscode-log-service-override": "3.2.2"
21
+ "vscode": "npm:@codingame/monaco-vscode-api@4.0.0",
22
+ "@codingame/monaco-vscode-log-service-override": "4.0.0"
23
23
  },
24
24
  "exports": {
25
25
  ".": {
@@ -4,9 +4,10 @@ import { KeyChord } from 'vscode/vscode/vs/base/common/keyCodes';
4
4
  import { ModesRegistry } from 'vscode/vscode/vs/editor/common/languages/modesRegistry';
5
5
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
6
6
  import { registerAction2, Action2, MenuId, MenuRegistry } from 'vscode/vscode/vs/platform/actions/common/actions';
7
- import { OUTPUT_MODE_ID, OUTPUT_MIME, LOG_MODE_ID, LOG_MIME, OUTPUT_VIEW_ID, IOutputService, Extensions as Extensions$3, CONTEXT_IN_OUTPUT, CONTEXT_OUTPUT_SCROLL_LOCK, CONTEXT_ACTIVE_FILE_OUTPUT, ACTIVE_OUTPUT_CHANNEL_CONTEXT } from 'vscode/vscode/vs/workbench/services/output/common/output';
8
- import { OutputViewPane } from './outputView.js';
9
7
  import { SyncDescriptor } from 'vscode/vscode/vs/platform/instantiation/common/descriptors';
8
+ import './outputServices.js';
9
+ import { OUTPUT_MODE_ID, OUTPUT_MIME, LOG_MODE_ID, LOG_MIME, OUTPUT_VIEW_ID, IOutputService, Extensions as Extensions$3, CONTEXT_IN_OUTPUT, CONTEXT_OUTPUT_SCROLL_LOCK, CONTEXT_ACTIVE_FILE_OUTPUT, CONTEXT_ACTIVE_OUTPUT_LEVEL_SETTABLE, CONTEXT_ACTIVE_OUTPUT_LEVEL_IS_DEFAULT, ACTIVE_OUTPUT_CHANNEL_CONTEXT, CONTEXT_ACTIVE_OUTPUT_LEVEL } from 'vscode/vscode/vs/workbench/services/output/common/output';
10
+ import { OutputViewPane } from './outputView.js';
10
11
  import { Extensions as Extensions$1 } from 'vscode/vscode/vs/workbench/common/contributions';
11
12
  import { Extensions } from 'vscode/vscode/vs/workbench/common/views';
12
13
  import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService';
@@ -22,6 +23,8 @@ import { Categories } from 'vscode/vscode/vs/platform/action/common/actionCommon
22
23
  import { Disposable, toDisposable, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
23
24
  import { IFilesConfigurationService } from 'vscode/vscode/vs/workbench/services/filesConfiguration/common/filesConfigurationService';
24
25
  import { IAccessibilitySignalService, AccessibilitySignal } from 'vscode/vscode/vs/platform/accessibilitySignal/browser/accessibilitySignalService';
26
+ import { LogLevel, ILoggerService, LogLevelToLocalizedString, LogLevelToString } from 'vscode/vscode/vs/platform/log/common/log';
27
+ import { IDefaultLogLevelsService } from 'vscode/vscode/vs/workbench/contrib/logs/common/defaultLogLevels';
25
28
 
26
29
  ModesRegistry.registerLanguage({
27
30
  id: OUTPUT_MODE_ID,
@@ -98,6 +101,7 @@ let OutputContribution = class OutputContribution extends Disposable {
98
101
  this.registerOpenActiveOutputFileInAuxWindowAction();
99
102
  this.registerShowLogsAction();
100
103
  this.registerOpenLogFileAction();
104
+ this.registerConfigureActiveOutputLogLevelAction();
101
105
  }
102
106
  registerSwitchOutputAction() {
103
107
  this._register(registerAction2(class extends Action2 {
@@ -369,6 +373,82 @@ let OutputContribution = class OutputContribution extends Disposable {
369
373
  }
370
374
  return null;
371
375
  }
376
+ registerConfigureActiveOutputLogLevelAction() {
377
+ const that = this;
378
+ const logLevelMenu = ( new MenuId('workbench.output.menu.logLevel'));
379
+ this._register(MenuRegistry.appendMenuItem(MenuId.ViewTitle, {
380
+ submenu: logLevelMenu,
381
+ title: ( localizeWithPath(
382
+ 'vs/workbench/contrib/output/browser/output.contribution',
383
+ 'logLevel.label',
384
+ "Set Log Level..."
385
+ )),
386
+ group: 'navigation',
387
+ when: ( ContextKeyExpr.and(( ContextKeyExpr.equals('view', OUTPUT_VIEW_ID)), CONTEXT_ACTIVE_OUTPUT_LEVEL_SETTABLE)),
388
+ icon: Codicon.gear,
389
+ order: 6
390
+ }));
391
+ let order = 0;
392
+ const registerLogLevel = (logLevel) => {
393
+ this._register(registerAction2(class extends Action2 {
394
+ constructor() {
395
+ super({
396
+ id: `workbench.action.output.activeOutputLogLevel.${logLevel}`,
397
+ title: LogLevelToLocalizedString(logLevel).value,
398
+ toggled: ( CONTEXT_ACTIVE_OUTPUT_LEVEL.isEqualTo(LogLevelToString(logLevel))),
399
+ menu: {
400
+ id: logLevelMenu,
401
+ order: order++,
402
+ group: '0_level'
403
+ }
404
+ });
405
+ }
406
+ async run(accessor) {
407
+ const channel = that.outputService.getActiveChannel();
408
+ if (channel) {
409
+ const channelDescriptor = that.outputService.getChannelDescriptor(channel.id);
410
+ if (channelDescriptor?.log && channelDescriptor.file) {
411
+ return accessor.get(ILoggerService).setLogLevel(channelDescriptor.file, logLevel);
412
+ }
413
+ }
414
+ }
415
+ }));
416
+ };
417
+ registerLogLevel(LogLevel.Trace);
418
+ registerLogLevel(LogLevel.Debug);
419
+ registerLogLevel(LogLevel.Info);
420
+ registerLogLevel(LogLevel.Warning);
421
+ registerLogLevel(LogLevel.Error);
422
+ registerLogLevel(LogLevel.Off);
423
+ this._register(registerAction2(class extends Action2 {
424
+ constructor() {
425
+ super({
426
+ id: `workbench.action.output.activeOutputLogLevelDefault`,
427
+ title: ( localizeWithPath(
428
+ 'vs/workbench/contrib/output/browser/output.contribution',
429
+ 'logLevelDefault.label',
430
+ "Set As Default"
431
+ )),
432
+ menu: {
433
+ id: logLevelMenu,
434
+ order,
435
+ group: '1_default'
436
+ },
437
+ precondition: ( CONTEXT_ACTIVE_OUTPUT_LEVEL_IS_DEFAULT.negate())
438
+ });
439
+ }
440
+ async run(accessor) {
441
+ const channel = that.outputService.getActiveChannel();
442
+ if (channel) {
443
+ const channelDescriptor = that.outputService.getChannelDescriptor(channel.id);
444
+ if (channelDescriptor?.log && channelDescriptor.file) {
445
+ const logLevel = accessor.get(ILoggerService).getLogLevel(channelDescriptor.file);
446
+ return await accessor.get(IDefaultLogLevelsService).setDefaultLogLevel(logLevel, channelDescriptor.extensionId);
447
+ }
448
+ }
449
+ }
450
+ }));
451
+ }
372
452
  registerShowLogsAction() {
373
453
  this._register(registerAction2(class extends Action2 {
374
454
  constructor() {
@@ -1,19 +1,21 @@
1
1
  import { __decorate, __param } from '../../../../../../../external/tslib/tslib.es6.js';
2
2
  import { Emitter, Event } from 'vscode/vscode/vs/base/common/event';
3
3
  import { URI } from 'vscode/vscode/vs/base/common/uri';
4
- import { Disposable, dispose } from 'vscode/vscode/vs/base/common/lifecycle';
4
+ import { Disposable } from 'vscode/vscode/vs/base/common/lifecycle';
5
5
  import { IInstantiationService } from 'vscode/vscode/vs/platform/instantiation/common/instantiation';
6
6
  import { IStorageService } from 'vscode/vscode/vs/platform/storage/common/storage';
7
7
  import { Registry } from 'vscode/vscode/vs/platform/registry/common/platform';
8
- import { OUTPUT_SCHEME, LOG_MIME, OUTPUT_MIME, ACTIVE_OUTPUT_CHANNEL_CONTEXT, CONTEXT_ACTIVE_FILE_OUTPUT, Extensions, OUTPUT_VIEW_ID } from 'vscode/vscode/vs/workbench/services/output/common/output';
8
+ import { OUTPUT_SCHEME, LOG_MIME, OUTPUT_MIME, ACTIVE_OUTPUT_CHANNEL_CONTEXT, CONTEXT_ACTIVE_FILE_OUTPUT, CONTEXT_ACTIVE_OUTPUT_LEVEL_SETTABLE, CONTEXT_ACTIVE_OUTPUT_LEVEL, CONTEXT_ACTIVE_OUTPUT_LEVEL_IS_DEFAULT, Extensions, OUTPUT_VIEW_ID } from 'vscode/vscode/vs/workbench/services/output/common/output';
9
9
  import { OutputLinkProvider } from './outputLinkProvider.js';
10
10
  import { ITextModelService } from 'vscode/vscode/vs/editor/common/services/resolverService';
11
- import { ILogService } from 'vscode/vscode/vs/platform/log/common/log';
11
+ import { LogLevelToString, ILogService, ILoggerService } from 'vscode/vscode/vs/platform/log/common/log';
12
12
  import { ILifecycleService } from 'vscode/vscode/vs/workbench/services/lifecycle/common/lifecycle';
13
13
  import { IViewsService } from 'vscode/vscode/vs/workbench/services/views/common/viewsService';
14
14
  import { IOutputChannelModelService } from 'vscode/vscode/vs/workbench/contrib/output/common/outputChannelModelService';
15
15
  import { ILanguageService } from 'vscode/vscode/vs/editor/common/languages/language';
16
16
  import { IContextKeyService } from 'vscode/vscode/vs/platform/contextkey/common/contextkey';
17
+ import { SetLogLevelAction } from 'vscode/vscode/vs/workbench/contrib/logs/common/logsActions';
18
+ import { IDefaultLogLevelsService } from 'vscode/vscode/vs/workbench/contrib/logs/common/defaultLogLevels';
17
19
 
18
20
  const OUTPUT_ACTIVE_CHANNEL_KEY = 'output.activechannel';
19
21
  let OutputChannel = class OutputChannel extends Disposable {
@@ -44,13 +46,15 @@ OutputChannel = ( __decorate([
44
46
  ( __param(2, ILanguageService))
45
47
  ], OutputChannel));
46
48
  let OutputService = class OutputService extends Disposable {
47
- constructor(storageService, instantiationService, textModelResolverService, logService, lifecycleService, viewsService, contextKeyService) {
49
+ constructor(storageService, instantiationService, textModelResolverService, logService, loggerService, lifecycleService, viewsService, contextKeyService, defaultLogLevelsService) {
48
50
  super();
49
51
  this.storageService = storageService;
50
52
  this.instantiationService = instantiationService;
51
53
  this.logService = logService;
54
+ this.loggerService = loggerService;
52
55
  this.lifecycleService = lifecycleService;
53
56
  this.viewsService = viewsService;
57
+ this.defaultLogLevelsService = defaultLogLevelsService;
54
58
  this.channels = ( new Map());
55
59
  this._onActiveOutputChannel = this._register(( new Emitter()));
56
60
  this.onActiveOutputChannel = this._onActiveOutputChannel.event;
@@ -59,6 +63,9 @@ let OutputService = class OutputService extends Disposable {
59
63
  this.activeOutputChannelContext.set(this.activeChannelIdInStorage);
60
64
  this._register(this.onActiveOutputChannel(channel => this.activeOutputChannelContext.set(channel)));
61
65
  this.activeFileOutputChannelContext = CONTEXT_ACTIVE_FILE_OUTPUT.bindTo(contextKeyService);
66
+ this.activeOutputChannelLevelSettableContext = CONTEXT_ACTIVE_OUTPUT_LEVEL_SETTABLE.bindTo(contextKeyService);
67
+ this.activeOutputChannelLevelContext = CONTEXT_ACTIVE_OUTPUT_LEVEL.bindTo(contextKeyService);
68
+ this.activeOutputChannelLevelIsDefaultContext = CONTEXT_ACTIVE_OUTPUT_LEVEL_IS_DEFAULT.bindTo(contextKeyService);
62
69
  textModelResolverService.registerTextModelContentProvider(OUTPUT_SCHEME, this);
63
70
  instantiationService.createInstance(OutputLinkProvider);
64
71
  const registry = ( Registry.as(Extensions.OutputChannels));
@@ -75,6 +82,13 @@ let OutputService = class OutputService extends Disposable {
75
82
  this.viewsService.getActiveViewWithId(OUTPUT_VIEW_ID)?.showChannel(this.activeChannel, true);
76
83
  }
77
84
  }));
85
+ this._register(this.loggerService.onDidChangeLogLevel(_level => {
86
+ this.setLevelContext();
87
+ this.setLevelIsDefaultContext();
88
+ }));
89
+ this._register(this.defaultLogLevelsService.onDidChangeDefaultLogLevels(() => {
90
+ this.setLevelIsDefaultContext();
91
+ }));
78
92
  this._register(this.lifecycleService.onDidShutdown(() => this.dispose()));
79
93
  }
80
94
  provideTextContent(resource) {
@@ -118,9 +132,8 @@ let OutputService = class OutputService extends Disposable {
118
132
  }
119
133
  }
120
134
  createChannel(id) {
121
- const channelDisposables = [];
122
135
  const channel = this.instantiateChannel(id);
123
- channel.model.onDispose(() => {
136
+ this._register(Event.once(channel.model.onDispose)(() => {
124
137
  if (this.activeChannel === channel) {
125
138
  const channels = this.getChannelDescriptors();
126
139
  const channel = channels.length ? this.getChannel(channels[0].id) : undefined;
@@ -132,8 +145,7 @@ let OutputService = class OutputService extends Disposable {
132
145
  }
133
146
  }
134
147
  ( Registry.as(Extensions.OutputChannels)).removeChannel(id);
135
- dispose(channelDisposables);
136
- }, channelDisposables);
148
+ }));
137
149
  return channel;
138
150
  }
139
151
  instantiateChannel(id) {
@@ -144,9 +156,29 @@ let OutputService = class OutputService extends Disposable {
144
156
  }
145
157
  return this.instantiationService.createInstance(OutputChannel, channelData);
146
158
  }
159
+ setLevelContext() {
160
+ const descriptor = this.activeChannel?.outputChannelDescriptor;
161
+ const channelLogLevel = descriptor?.log ? this.loggerService.getLogLevel(descriptor.file) : undefined;
162
+ this.activeOutputChannelLevelContext.set(channelLogLevel !== undefined ? LogLevelToString(channelLogLevel) : '');
163
+ }
164
+ async setLevelIsDefaultContext() {
165
+ const descriptor = this.activeChannel?.outputChannelDescriptor;
166
+ if (descriptor?.log) {
167
+ const channelLogLevel = this.loggerService.getLogLevel(descriptor.file);
168
+ const channelDefaultLogLevel = await this.defaultLogLevelsService.getDefaultLogLevel(descriptor.extensionId);
169
+ this.activeOutputChannelLevelIsDefaultContext.set(channelDefaultLogLevel === channelLogLevel);
170
+ }
171
+ else {
172
+ this.activeOutputChannelLevelIsDefaultContext.set(false);
173
+ }
174
+ }
147
175
  setActiveChannel(channel) {
148
176
  this.activeChannel = channel;
149
- this.activeFileOutputChannelContext.set(!!channel?.outputChannelDescriptor?.file);
177
+ const descriptor = channel?.outputChannelDescriptor;
178
+ this.activeFileOutputChannelContext.set(!!descriptor?.file);
179
+ this.activeOutputChannelLevelSettableContext.set(descriptor !== undefined && SetLogLevelAction.isLevelSettable(descriptor));
180
+ this.setLevelIsDefaultContext();
181
+ this.setLevelContext();
150
182
  if (this.activeChannel) {
151
183
  this.storageService.store(OUTPUT_ACTIVE_CHANNEL_KEY, this.activeChannel.id, 1 , 1 );
152
184
  }
@@ -160,9 +192,11 @@ OutputService = ( __decorate([
160
192
  ( __param(1, IInstantiationService)),
161
193
  ( __param(2, ITextModelService)),
162
194
  ( __param(3, ILogService)),
163
- ( __param(4, ILifecycleService)),
164
- ( __param(5, IViewsService)),
165
- ( __param(6, IContextKeyService))
195
+ ( __param(4, ILoggerService)),
196
+ ( __param(5, ILifecycleService)),
197
+ ( __param(6, IViewsService)),
198
+ ( __param(7, IContextKeyService)),
199
+ ( __param(8, IDefaultLogLevelsService))
166
200
  ], OutputService));
167
201
 
168
202
  export { OutputService };
@@ -23,6 +23,7 @@ import { createCancelablePromise } from 'vscode/vscode/vs/base/common/async';
23
23
  import { IFileService } from 'vscode/vscode/vs/platform/files/common/files';
24
24
  import { ResourceContextKey } from 'vscode/vscode/vs/workbench/common/contextkeys';
25
25
  import { ServiceCollection } from 'vscode/vscode/vs/platform/instantiation/common/serviceCollection';
26
+ import { computeEditorAriaLabel } from 'vscode/vscode/vs/workbench/browser/editor';
26
27
 
27
28
  let OutputViewPane = class OutputViewPane extends ViewPane {
28
29
  get scrollLock() { return !!this.scrollLockContextKey.get(); }
@@ -127,8 +128,8 @@ OutputViewPane = ( __decorate([
127
128
  ( __param(9, ITelemetryService))
128
129
  ], OutputViewPane));
129
130
  let OutputEditor = class OutputEditor extends AbstractTextResourceEditor {
130
- constructor(telemetryService, instantiationService, storageService, configurationService, textResourceConfigurationService, themeService, editorGroupService, editorService, fileService, contextKeyService) {
131
- super(OUTPUT_VIEW_ID, telemetryService, instantiationService, storageService, textResourceConfigurationService, themeService, editorGroupService, editorService, fileService);
131
+ constructor(telemetryService, instantiationService, storageService, configurationService, textResourceConfigurationService, themeService, editorGroupService, editorService, fileService) {
132
+ super(OUTPUT_VIEW_ID, editorGroupService.activeGroup , telemetryService, instantiationService, storageService, textResourceConfigurationService, themeService, editorGroupService, editorService, fileService);
132
133
  this.configurationService = configurationService;
133
134
  this.resourceContext = this._register(instantiationService.createInstance(ResourceContextKey));
134
135
  }
@@ -176,6 +177,9 @@ let OutputEditor = class OutputEditor extends AbstractTextResourceEditor {
176
177
  "Output panel"
177
178
  ));
178
179
  }
180
+ computeAriaLabel() {
181
+ return this.input ? computeEditorAriaLabel(this.input, undefined, undefined, this.editorGroupService.count) : this.getAriaLabel();
182
+ }
179
183
  async setInput(input, options, context, token) {
180
184
  const focus = !(options && options.preserveFocus);
181
185
  if (this.input && input.matches(this.input)) {
@@ -216,8 +220,7 @@ OutputEditor = ( __decorate([
216
220
  ( __param(5, IThemeService)),
217
221
  ( __param(6, IEditorGroupsService)),
218
222
  ( __param(7, IEditorService)),
219
- ( __param(8, IFileService)),
220
- ( __param(9, IContextKeyService))
223
+ ( __param(8, IFileService))
221
224
  ], OutputEditor));
222
225
 
223
226
  export { OutputViewPane };
@@ -55,7 +55,7 @@ class OutputLinkComputer {
55
55
  workspaceFolderVariants.push(toSlashes(workspaceFolderPath));
56
56
  }
57
57
  for (const workspaceFolderVariant of workspaceFolderVariants) {
58
- const validPathCharacterPattern = '[^\\s\\(\\):<>"]';
58
+ const validPathCharacterPattern = '[^\\s\\(\\):<>\'"]';
59
59
  const validPathCharacterOrSpacePattern = `(?:${validPathCharacterPattern}| ${validPathCharacterPattern})`;
60
60
  const pathPattern = `${validPathCharacterOrSpacePattern}+\\.${validPathCharacterPattern}+`;
61
61
  const strictPathPattern = `${validPathCharacterPattern}+`;