@codingame/monaco-vscode-theme-service-override 28.4.1 → 29.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.
@@ -32,7 +32,7 @@ const COLOR_THEME_CONFIGURATION_SETTINGS_TAG = "colorThemeConfiguration";
32
32
  const colorThemeSettingSchema = {
33
33
  type: "string",
34
34
  markdownDescription: ( localize(
35
- 16147,
35
+ 16445,
36
36
  "Specifies the color theme used in the workbench when {0} is not enabled.",
37
37
  formatSettingAsLink(ThemeSettings.DETECT_COLOR_SCHEME)
38
38
  )),
@@ -41,12 +41,12 @@ const colorThemeSettingSchema = {
41
41
  enum: colorThemeSettingEnum,
42
42
  enumDescriptions: colorThemeSettingEnumDescriptions,
43
43
  enumItemLabels: colorThemeSettingEnumItemLabels,
44
- errorMessage: ( localize(16148, "Theme is unknown or not installed."))
44
+ errorMessage: ( localize(16446, "Theme is unknown or not installed."))
45
45
  };
46
46
  const preferredDarkThemeSettingSchema = {
47
47
  type: "string",
48
48
  markdownDescription: ( localize(
49
- 16149,
49
+ 16447,
50
50
  "Specifies the color theme when system color mode is dark and {0} is enabled.",
51
51
  formatSettingAsLink(ThemeSettings.DETECT_COLOR_SCHEME)
52
52
  )),
@@ -55,12 +55,12 @@ const preferredDarkThemeSettingSchema = {
55
55
  enum: colorThemeSettingEnum,
56
56
  enumDescriptions: colorThemeSettingEnumDescriptions,
57
57
  enumItemLabels: colorThemeSettingEnumItemLabels,
58
- errorMessage: ( localize(16148, "Theme is unknown or not installed."))
58
+ errorMessage: ( localize(16446, "Theme is unknown or not installed."))
59
59
  };
60
60
  const preferredLightThemeSettingSchema = {
61
61
  type: "string",
62
62
  markdownDescription: ( localize(
63
- 16150,
63
+ 16448,
64
64
  "Specifies the color theme when system color mode is light and {0} is enabled.",
65
65
  formatSettingAsLink(ThemeSettings.DETECT_COLOR_SCHEME)
66
66
  )),
@@ -69,12 +69,12 @@ const preferredLightThemeSettingSchema = {
69
69
  enum: colorThemeSettingEnum,
70
70
  enumDescriptions: colorThemeSettingEnumDescriptions,
71
71
  enumItemLabels: colorThemeSettingEnumItemLabels,
72
- errorMessage: ( localize(16148, "Theme is unknown or not installed."))
72
+ errorMessage: ( localize(16446, "Theme is unknown or not installed."))
73
73
  };
74
74
  const preferredHCDarkThemeSettingSchema = {
75
75
  type: "string",
76
76
  markdownDescription: ( localize(
77
- 16151,
77
+ 16449,
78
78
  "Specifies the color theme when in high contrast dark mode and {0} is enabled.",
79
79
  formatSettingAsLink(ThemeSettings.DETECT_HC)
80
80
  )),
@@ -83,12 +83,12 @@ const preferredHCDarkThemeSettingSchema = {
83
83
  enum: colorThemeSettingEnum,
84
84
  enumDescriptions: colorThemeSettingEnumDescriptions,
85
85
  enumItemLabels: colorThemeSettingEnumItemLabels,
86
- errorMessage: ( localize(16148, "Theme is unknown or not installed."))
86
+ errorMessage: ( localize(16446, "Theme is unknown or not installed."))
87
87
  };
88
88
  const preferredHCLightThemeSettingSchema = {
89
89
  type: "string",
90
90
  markdownDescription: ( localize(
91
- 16152,
91
+ 16450,
92
92
  "Specifies the color theme when in high contrast light mode and {0} is enabled.",
93
93
  formatSettingAsLink(ThemeSettings.DETECT_HC)
94
94
  )),
@@ -97,12 +97,12 @@ const preferredHCLightThemeSettingSchema = {
97
97
  enum: colorThemeSettingEnum,
98
98
  enumDescriptions: colorThemeSettingEnumDescriptions,
99
99
  enumItemLabels: colorThemeSettingEnumItemLabels,
100
- errorMessage: ( localize(16148, "Theme is unknown or not installed."))
100
+ errorMessage: ( localize(16446, "Theme is unknown or not installed."))
101
101
  };
102
102
  const detectColorSchemeSettingSchema = {
103
103
  type: "boolean",
104
104
  markdownDescription: ( localize(
105
- 16153,
105
+ 16451,
106
106
  "If enabled, will automatically select a color theme based on the system color mode. If the system color mode is dark, {0} is used, else {1}.",
107
107
  formatSettingAsLink(ThemeSettings.PREFERRED_DARK_THEME),
108
108
  formatSettingAsLink(ThemeSettings.PREFERRED_LIGHT_THEME)
@@ -112,7 +112,7 @@ const detectColorSchemeSettingSchema = {
112
112
  };
113
113
  const colorCustomizationsSchema = {
114
114
  type: "object",
115
- description: ( localize(16154, "Overrides colors from the currently selected color theme.")),
115
+ description: ( localize(16452, "Overrides colors from the currently selected color theme.")),
116
116
  allOf: [{
117
117
  $ref: workbenchColorsSchemaId
118
118
  }],
@@ -125,28 +125,28 @@ const fileIconThemeSettingSchema = {
125
125
  type: ["string", "null"],
126
126
  default: ThemeSettingDefaults.FILE_ICON_THEME,
127
127
  description: ( localize(
128
- 16155,
128
+ 16453,
129
129
  "Specifies the file icon theme used in the workbench or 'null' to not show any file icons."
130
130
  )),
131
131
  enum: [null],
132
- enumItemLabels: [( localize(16156, "None"))],
133
- enumDescriptions: [( localize(16157, "No file icons"))],
134
- errorMessage: ( localize(16158, "File icon theme is unknown or not installed."))
132
+ enumItemLabels: [( localize(16454, "None"))],
133
+ enumDescriptions: [( localize(16455, "No file icons"))],
134
+ errorMessage: ( localize(16456, "File icon theme is unknown or not installed."))
135
135
  };
136
136
  const productIconThemeSettingSchema = {
137
137
  type: ["string", "null"],
138
138
  default: ThemeSettingDefaults.PRODUCT_ICON_THEME,
139
- description: ( localize(16159, "Specifies the product icon theme used.")),
139
+ description: ( localize(16457, "Specifies the product icon theme used.")),
140
140
  enum: [ThemeSettingDefaults.PRODUCT_ICON_THEME],
141
- enumItemLabels: [( localize(16160, "Default"))],
142
- enumDescriptions: [( localize(16161, "Default"))],
143
- errorMessage: ( localize(16162, "Product icon theme is unknown or not installed."))
141
+ enumItemLabels: [( localize(16458, "Default"))],
142
+ enumDescriptions: [( localize(16459, "Default"))],
143
+ errorMessage: ( localize(16460, "Product icon theme is unknown or not installed."))
144
144
  };
145
145
  const detectHCSchemeSettingSchema = {
146
146
  type: "boolean",
147
147
  default: true,
148
148
  markdownDescription: ( localize(
149
- 16163,
149
+ 16461,
150
150
  "If enabled, will automatically change to high contrast theme if the OS is using a high contrast theme. The high contrast theme to use is specified by {0} and {1}.",
151
151
  formatSettingAsLink(ThemeSettings.PREFERRED_HC_DARK_THEME),
152
152
  formatSettingAsLink(ThemeSettings.PREFERRED_HC_LIGHT_THEME)
@@ -190,31 +190,31 @@ const themeSpecificSettingKey = "^\\[[^\\]]*(\\]\\s*\\[[^\\]]*)*\\]$";
190
190
  const tokenColorSchema = {
191
191
  type: "object",
192
192
  properties: {
193
- comments: tokenGroupSettings(( localize(16164, "Sets the colors and styles for comments"))),
194
- strings: tokenGroupSettings(( localize(16165, "Sets the colors and styles for strings literals."))),
195
- keywords: tokenGroupSettings(( localize(16166, "Sets the colors and styles for keywords."))),
196
- numbers: tokenGroupSettings(( localize(16167, "Sets the colors and styles for number literals."))),
197
- types: tokenGroupSettings(( localize(16168, "Sets the colors and styles for type declarations and references."))),
193
+ comments: tokenGroupSettings(( localize(16462, "Sets the colors and styles for comments"))),
194
+ strings: tokenGroupSettings(( localize(16463, "Sets the colors and styles for strings literals."))),
195
+ keywords: tokenGroupSettings(( localize(16464, "Sets the colors and styles for keywords."))),
196
+ numbers: tokenGroupSettings(( localize(16465, "Sets the colors and styles for number literals."))),
197
+ types: tokenGroupSettings(( localize(16466, "Sets the colors and styles for type declarations and references."))),
198
198
  functions: tokenGroupSettings(( localize(
199
- 16169,
199
+ 16467,
200
200
  "Sets the colors and styles for functions declarations and references."
201
201
  ))),
202
202
  variables: tokenGroupSettings(( localize(
203
- 16170,
203
+ 16468,
204
204
  "Sets the colors and styles for variables declarations and references."
205
205
  ))),
206
206
  textMateRules: {
207
- description: ( localize(16171, "Sets colors and styles using textmate theming rules (advanced).")),
207
+ description: ( localize(16469, "Sets colors and styles using textmate theming rules (advanced).")),
208
208
  $ref: textmateColorsSchemaId
209
209
  },
210
210
  semanticHighlighting: {
211
- description: ( localize(16172, "Whether semantic highlighting should be enabled for this theme.")),
211
+ description: ( localize(16470, "Whether semantic highlighting should be enabled for this theme.")),
212
212
  deprecationMessage: ( localize(
213
- 16173,
213
+ 16471,
214
214
  "Use `enabled` in `editor.semanticTokenColorCustomizations` setting instead."
215
215
  )),
216
216
  markdownDeprecationMessage: ( localize(
217
- 16174,
217
+ 16472,
218
218
  "Use `enabled` in {0} setting instead.",
219
219
  formatSettingAsLink("editor.semanticTokenColorCustomizations")
220
220
  )),
@@ -225,7 +225,7 @@ const tokenColorSchema = {
225
225
  };
226
226
  const tokenColorCustomizationSchema = {
227
227
  description: ( localize(
228
- 16175,
228
+ 16473,
229
229
  "Overrides editor syntax colors and font style from the currently selected color theme."
230
230
  )),
231
231
  default: {},
@@ -242,14 +242,14 @@ const semanticTokenColorSchema = {
242
242
  enabled: {
243
243
  type: "boolean",
244
244
  description: ( localize(
245
- 16176,
245
+ 16474,
246
246
  "Whether semantic highlighting is enabled or disabled for this theme"
247
247
  )),
248
248
  suggestSortText: "0_enabled"
249
249
  },
250
250
  rules: {
251
251
  $ref: tokenStylingSchemaId,
252
- description: ( localize(16177, "Semantic token styling rules for this theme.")),
252
+ description: ( localize(16475, "Semantic token styling rules for this theme.")),
253
253
  suggestSortText: "0_rules"
254
254
  }
255
255
  },
@@ -257,7 +257,7 @@ const semanticTokenColorSchema = {
257
257
  };
258
258
  const semanticTokenColorCustomizationSchema = {
259
259
  description: ( localize(
260
- 16178,
260
+ 16476,
261
261
  "Overrides editor semantic token color and styles from the currently selected color theme."
262
262
  )),
263
263
  default: {},
@@ -339,9 +339,26 @@ const colorSchemeToPreferred = {
339
339
  [ColorScheme.HIGH_CONTRAST_LIGHT]: ThemeSettings.PREFERRED_HC_LIGHT_THEME
340
340
  };
341
341
  class ThemeConfiguration {
342
- constructor(configurationService, hostColorService) {
342
+ constructor(configurationService, hostColorService, isNewUser = false) {
343
343
  this.configurationService = configurationService;
344
344
  this.hostColorService = hostColorService;
345
+ this.isNewUser = isNewUser;
346
+ }
347
+ shouldAutoDetectColorScheme() {
348
+ const {
349
+ value,
350
+ userValue,
351
+ userLocalValue,
352
+ userRemoteValue
353
+ } = this.configurationService.inspect(ThemeSettings.DETECT_COLOR_SCHEME);
354
+ if (value) {
355
+ return true;
356
+ }
357
+ if (this.isNewUser) {
358
+ const hasUserScopedValue = userValue !== undefined || userLocalValue !== undefined || userRemoteValue !== undefined;
359
+ return !hasUserScopedValue;
360
+ }
361
+ return false;
345
362
  }
346
363
  get colorTheme() {
347
364
  return this.configurationService.getValue(this.getColorThemeSettingId());
@@ -388,13 +405,13 @@ class ThemeConfiguration {
388
405
  if (this.configurationService.getValue(ThemeSettings.DETECT_HC) && this.hostColorService.highContrast) {
389
406
  return this.hostColorService.dark ? ColorScheme.HIGH_CONTRAST_DARK : ColorScheme.HIGH_CONTRAST_LIGHT;
390
407
  }
391
- if (this.configurationService.getValue(ThemeSettings.DETECT_COLOR_SCHEME)) {
408
+ if (this.shouldAutoDetectColorScheme()) {
392
409
  return this.hostColorService.dark ? ColorScheme.DARK : ColorScheme.LIGHT;
393
410
  }
394
411
  return undefined;
395
412
  }
396
413
  isDetectingColorScheme() {
397
- return this.configurationService.getValue(ThemeSettings.DETECT_COLOR_SCHEME);
414
+ return this.shouldAutoDetectColorScheme();
398
415
  }
399
416
  getColorThemeSettingId() {
400
417
  const preferredScheme = this.getPreferredColorScheme();
@@ -3,7 +3,7 @@ import { localize } from '@codingame/monaco-vscode-api/vscode/vs/nls';
3
3
  import { isString } from '@codingame/monaco-vscode-api/vscode/vs/base/common/types';
4
4
  import { joinPath, isEqualOrParent } from '@codingame/monaco-vscode-api/vscode/vs/base/common/resources';
5
5
  import { ExtensionsRegistry } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensions/common/extensionsRegistry';
6
- import { ExtensionData } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/themes/common/workbenchThemeService';
6
+ import { ExtensionData, migrateThemeSettingsId } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/themes/common/workbenchThemeService';
7
7
  import { Emitter } from '@codingame/monaco-vscode-api/vscode/vs/base/common/event';
8
8
  import { Disposable } from '@codingame/monaco-vscode-api/vscode/vs/base/common/lifecycle';
9
9
  import { Extensions } from '@codingame/monaco-vscode-api/vscode/vs/workbench/services/extensionManagement/common/extensionFeatures';
@@ -16,7 +16,7 @@ function registerColorThemeExtensionPoint() {
16
16
  return ExtensionsRegistry.registerExtensionPoint({
17
17
  extensionPoint: "themes",
18
18
  jsonSchema: {
19
- description: ( localize(16179, "Contributes textmate color themes.")),
19
+ description: ( localize(16477, "Contributes textmate color themes.")),
20
20
  type: "array",
21
21
  items: {
22
22
  type: "object",
@@ -30,17 +30,17 @@ function registerColorThemeExtensionPoint() {
30
30
  }],
31
31
  properties: {
32
32
  id: {
33
- description: ( localize(16180, "Id of the color theme as used in the user settings.")),
33
+ description: ( localize(16478, "Id of the color theme as used in the user settings.")),
34
34
  type: "string"
35
35
  },
36
36
  label: {
37
- description: ( localize(16181, "Label of the color theme as shown in the UI.")),
37
+ description: ( localize(16479, "Label of the color theme as shown in the UI.")),
38
38
  type: "string"
39
39
  },
40
40
  uiTheme: {
41
- description: ( localize(
42
- 16182,
43
- "Base theme defining the colors around the editor: 'vs' is the light color theme, 'vs-dark' is the dark color theme. 'hc-black' is the dark high contrast theme, 'hc-light' is the light high contrast theme."
41
+ markdownDescription: ( localize(
42
+ 16480,
43
+ "Base theme defining the colors around the editor: `vs` is the light color theme, `vs-dark` is the dark color theme. `hc-black` is the dark high contrast theme, `hc-light` is the light high contrast theme."
44
44
  )),
45
45
  enum: [
46
46
  ThemeTypeSelector.VS,
@@ -50,9 +50,9 @@ function registerColorThemeExtensionPoint() {
50
50
  ]
51
51
  },
52
52
  path: {
53
- description: ( localize(
54
- 16183,
55
- "Path of the tmTheme file. The path is relative to the extension folder and is typically './colorthemes/awesome-color-theme.json'."
53
+ markdownDescription: ( localize(
54
+ 16481,
55
+ "Path of the tmTheme file. The path is relative to the extension folder and is typically `./colorthemes/awesome-color-theme.json`."
56
56
  )),
57
57
  type: "string"
58
58
  }
@@ -66,7 +66,7 @@ function registerFileIconThemeExtensionPoint() {
66
66
  return ExtensionsRegistry.registerExtensionPoint({
67
67
  extensionPoint: "iconThemes",
68
68
  jsonSchema: {
69
- description: ( localize(16184, "Contributes file icon themes.")),
69
+ description: ( localize(16482, "Contributes file icon themes.")),
70
70
  type: "array",
71
71
  items: {
72
72
  type: "object",
@@ -79,16 +79,16 @@ function registerFileIconThemeExtensionPoint() {
79
79
  }],
80
80
  properties: {
81
81
  id: {
82
- description: ( localize(16185, "Id of the file icon theme as used in the user settings.")),
82
+ description: ( localize(16483, "Id of the file icon theme as used in the user settings.")),
83
83
  type: "string"
84
84
  },
85
85
  label: {
86
- description: ( localize(16186, "Label of the file icon theme as shown in the UI.")),
86
+ description: ( localize(16484, "Label of the file icon theme as shown in the UI.")),
87
87
  type: "string"
88
88
  },
89
89
  path: {
90
90
  description: ( localize(
91
- 16187,
91
+ 16485,
92
92
  "Path of the file icon theme definition file. The path is relative to the extension folder and is typically './fileicons/awesome-icon-theme.json'."
93
93
  )),
94
94
  type: "string"
@@ -103,7 +103,7 @@ function registerProductIconThemeExtensionPoint() {
103
103
  return ExtensionsRegistry.registerExtensionPoint({
104
104
  extensionPoint: "productIconThemes",
105
105
  jsonSchema: {
106
- description: ( localize(16188, "Contributes product icon themes.")),
106
+ description: ( localize(16486, "Contributes product icon themes.")),
107
107
  type: "array",
108
108
  items: {
109
109
  type: "object",
@@ -116,16 +116,16 @@ function registerProductIconThemeExtensionPoint() {
116
116
  }],
117
117
  properties: {
118
118
  id: {
119
- description: ( localize(16189, "Id of the product icon theme as used in the user settings.")),
119
+ description: ( localize(16487, "Id of the product icon theme as used in the user settings.")),
120
120
  type: "string"
121
121
  },
122
122
  label: {
123
- description: ( localize(16190, "Label of the product icon theme as shown in the UI.")),
123
+ description: ( localize(16488, "Label of the product icon theme as shown in the UI.")),
124
124
  type: "string"
125
125
  },
126
126
  path: {
127
127
  description: ( localize(
128
- 16191,
128
+ 16489,
129
129
  "Path of the product icon theme definition file. The path is relative to the extension folder and is typically './producticons/awesome-product-icon-theme.json'."
130
130
  )),
131
131
  type: "string"
@@ -147,19 +147,19 @@ class ThemeDataRenderer extends Disposable {
147
147
  render(manifest) {
148
148
  const markdown = ( new MarkdownString());
149
149
  if (manifest.contributes?.themes) {
150
- markdown.appendMarkdown(`### ${( localize(16192, "Color Themes"))}\n\n`);
150
+ markdown.appendMarkdown(`### ${( localize(16490, "Color Themes"))}\n\n`);
151
151
  for (const theme of manifest.contributes.themes) {
152
152
  markdown.appendMarkdown(`- ${theme.label}\n`);
153
153
  }
154
154
  }
155
155
  if (manifest.contributes?.iconThemes) {
156
- markdown.appendMarkdown(`### ${( localize(16193, "File Icon Themes"))}\n\n`);
156
+ markdown.appendMarkdown(`### ${( localize(16491, "File Icon Themes"))}\n\n`);
157
157
  for (const theme of manifest.contributes.iconThemes) {
158
158
  markdown.appendMarkdown(`- ${theme.label}\n`);
159
159
  }
160
160
  }
161
161
  if (manifest.contributes?.productIconThemes) {
162
- markdown.appendMarkdown(`### ${( localize(16194, "Product Icon Themes"))}\n\n`);
162
+ markdown.appendMarkdown(`### ${( localize(16492, "Product Icon Themes"))}\n\n`);
163
163
  for (const theme of manifest.contributes.productIconThemes) {
164
164
  markdown.appendMarkdown(`- ${theme.label}\n`);
165
165
  }
@@ -172,7 +172,7 @@ class ThemeDataRenderer extends Disposable {
172
172
  }
173
173
  ( Registry.as(Extensions.ExtensionFeaturesRegistry)).registerExtensionFeature({
174
174
  id: "themes",
175
- label: ( localize(16195, "Themes")),
175
+ label: ( localize(16493, "Themes")),
176
176
  access: {
177
177
  canToggle: false
178
178
  },
@@ -234,13 +234,13 @@ class ThemeRegistry {
234
234
  log
235
235
  ) {
236
236
  if (!Array.isArray(themeContributions)) {
237
- log?.error(( localize(16196, "Extension point `{0}` must be an array.", this.themesExtPoint.name)));
237
+ log?.error(( localize(16494, "Extension point `{0}` must be an array.", this.themesExtPoint.name)));
238
238
  return resultingThemes;
239
239
  }
240
240
  themeContributions.forEach(theme => {
241
241
  if (!theme.path || !isString(theme.path)) {
242
242
  log?.error(( localize(
243
- 16197,
243
+ 16495,
244
244
  "Expected string in `contributes.{0}.path`. Provided value: {1}",
245
245
  this.themesExtPoint.name,
246
246
  String(theme.path)
@@ -249,7 +249,7 @@ class ThemeRegistry {
249
249
  }
250
250
  if (this.idRequired && (!theme.id || !isString(theme.id))) {
251
251
  log?.error(( localize(
252
- 16198,
252
+ 16496,
253
253
  "Expected string in `contributes.{0}.id`. Provided value: {1}",
254
254
  this.themesExtPoint.name,
255
255
  String(theme.id)
@@ -259,7 +259,7 @@ class ThemeRegistry {
259
259
  const themeLocation = joinPath(extensionLocation, theme.path);
260
260
  if (!isEqualOrParent(themeLocation, extensionLocation)) {
261
261
  log?.warn(( localize(
262
- 16199,
262
+ 16497,
263
263
  "Expected `contributes.{0}.path` ({1}) to be included inside extension's folder ({2}). This might make the extension non-portable.",
264
264
  this.themesExtPoint.name,
265
265
  themeLocation.path,
@@ -284,13 +284,14 @@ class ThemeRegistry {
284
284
  return undefined;
285
285
  }
286
286
  findThemeBySettingsId(settingsId, defaultSettingsId) {
287
- if (this.builtInTheme && this.builtInTheme.settingsId === settingsId) {
287
+ const migratedId = settingsId ? migrateThemeSettingsId(settingsId) : settingsId;
288
+ if (this.builtInTheme && this.builtInTheme.settingsId === migratedId) {
288
289
  return this.builtInTheme;
289
290
  }
290
291
  const allThemes = this.getThemes();
291
292
  let defaultTheme = undefined;
292
293
  for (const t of allThemes) {
293
- if (t.settingsId === settingsId) {
294
+ if (t.settingsId === migratedId) {
294
295
  return t;
295
296
  }
296
297
  if (t.settingsId === defaultSettingsId) {