Skip to content

Commit 0f13c7f

Browse files
authored
Merge pull request #711 from CodinGame/lmn/fix-theme-color-synchronization
Fix theme color synchronization in firefox
2 parents 79d62fa + 88fdc09 commit 0f13c7f

5 files changed

Lines changed: 11 additions & 83 deletions

File tree

src/contributions.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -23,3 +23,4 @@ import 'vs/workbench/contrib/codeEditor/browser/editorFeatures'
2323
import 'vs/workbench/contrib/contextmenu/browser/contextmenu.contribution'
2424
import 'vs/workbench/browser/actions/textInputActions'
2525
import 'vs/workbench/browser/actions/developerActions'
26+
import 'vs/workbench/contrib/dropOrPasteInto/browser/dropOrPasteInto.contribution'

src/missing-services.ts

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -5159,6 +5159,7 @@ class LanguageModelToolsService implements ILanguageModelToolsService {
51595159
registerToolData: ILanguageModelToolsService['registerToolData'] = () => Disposable.None
51605160
registerToolImplementation: ILanguageModelToolsService['registerToolImplementation'] = () =>
51615161
Disposable.None
5162+
registerTool: ILanguageModelToolsService['registerTool'] = () => Disposable.None
51625163
getTools: ILanguageModelToolsService['getTools'] = () => []
51635164
@Unsupported
51645165
invokeTool: ILanguageModelToolsService['invokeTool'] = unsupported
@@ -5179,8 +5180,7 @@ class LanguageModelToolsService implements ILanguageModelToolsService {
51795180
@Unsupported
51805181
toToolAndToolSetEnablementMap: ILanguageModelToolsService['toToolAndToolSetEnablementMap'] =
51815182
unsupported
5182-
@Unsupported
5183-
registerTool: ILanguageModelToolsService['registerTool'] = unsupported
5183+
51845184
@Unsupported
51855185
getToolAutoConfirmation: ILanguageModelToolsService['getToolAutoConfirmation'] = unsupported
51865186

src/service-override/textmate.ts

Lines changed: 2 additions & 17 deletions
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,11 @@
1-
import {
2-
type IEditorOverrideServices,
3-
StandaloneServices
4-
} from 'vs/editor/standalone/browser/standaloneServices'
1+
import { type IEditorOverrideServices } from 'vs/editor/standalone/browser/standaloneServices'
52
import { ITextMateTokenizationService } from 'vs/workbench/services/textMate/browser/textMateTokenizationFeature.service'
63
import { SyncDescriptor } from 'vs/platform/instantiation/common/descriptors'
74
import { TextMateTokenizationFeature } from 'vs/workbench/services/textMate/browser/textMateTokenizationFeatureImpl'
8-
import { LifecyclePhase } from 'vs/workbench/services/lifecycle/common/lifecycle'
9-
import { ILifecycleService } from 'vs/workbench/services/lifecycle/common/lifecycle.service'
105
import getFileServiceOverride from './files'
11-
import { registerServiceInitializeParticipant } from '../lifecycle'
126
import 'vs/workbench/services/themes/common/tokenClassificationExtensionPoint'
137
import 'vs/workbench/contrib/codeEditor/browser/inspectEditorTokens/inspectEditorTokens'
14-
15-
registerServiceInitializeParticipant(async (accessor) => {
16-
void accessor
17-
.get(ILifecycleService)
18-
.when(LifecyclePhase.Ready)
19-
.then(() => {
20-
// Force load the service
21-
StandaloneServices.get(ITextMateTokenizationService)
22-
})
23-
})
8+
import 'vs/workbench/services/textMate/browser/textMateTokenizationFeature.contribution'
249

2510
export default function getServiceOverride(): IEditorOverrideServices {
2611
return {

src/service-override/viewCommon.ts

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -65,6 +65,7 @@ import 'vs/workbench/contrib/files/browser/files.contribution._editorPane.js'
6565
import 'vs/workbench/contrib/files/browser/fileCommands._save.js'
6666
import 'vs/workbench/browser/actions/navigationActions'
6767
import 'vs/workbench/browser/style'
68+
import 'vs/workbench/contrib/scrollLocking/browser/scrollLocking.contribution'
6869
import './tools/editorAssets.js'
6970

7071
// Import it from here to force the bundler to put it in this service-override package

vscode-patches/0073-fix-update-style-id-attribute-when-the-content-chang.patch

Lines changed: 5 additions & 64 deletions
Original file line numberDiff line numberDiff line change
@@ -5,78 +5,19 @@ Subject: [PATCH] fix: update style id attribute when the content changes
55

66
so it can be watched in firefox
77
---
8-
src/vs/base/browser/domStylesheets.ts | 12 +++++++++-
9-
.../themes/browser/workbenchThemeService.ts | 23 ++++++++++++-------
10-
2 files changed, 26 insertions(+), 9 deletions(-)
8+
src/vs/base/browser/domStylesheets.ts | 2 +-
9+
1 file changed, 1 insertion(+), 1 deletion(-)
1110

1211
diff --git a/src/vs/base/browser/domStylesheets.ts b/src/vs/base/browser/domStylesheets.ts
13-
index bb699646f05..3d935cf440b 100644
12+
index bb699646f05..dd89c88aa54 100644
1413
--- a/src/vs/base/browser/domStylesheets.ts
1514
+++ b/src/vs/base/browser/domStylesheets.ts
16-
@@ -6,6 +6,7 @@
17-
import { DisposableStore, toDisposable, IDisposable } from '../common/lifecycle.js';
18-
import { autorun, IObservable } from '../common/observable.js';
19-
import { createElement, getWindows, isShadowRoot, sharedMutationObserver } from './dom.js';
20-
+import { isFirefox } from './browser.js';
21-
import { mainWindow } from './window.js';
22-
23-
const globalStylesheets = new Map<HTMLStyleElement /* main stylesheet */, Set<HTMLStyleElement /* aux window clones that track the main stylesheet */>>();
24-
@@ -111,7 +112,16 @@ function cloneGlobalStyleSheet(globalStylesheet: HTMLStyleElement, globalStylesh
15+
@@ -111,7 +111,7 @@ function cloneGlobalStyleSheet(globalStylesheet: HTMLStyleElement, globalStylesh
2516
clone.sheet?.insertRule(rule.cssText, clone.sheet?.cssRules.length);
2617
}
2718

2819
- disposables.add(sharedMutationObserver.observe(globalStylesheet, disposables, { childList: true })(() => {
29-
+ let observeInit: MutationObserverInit = {
30-
+ childList: true
31-
+ };
32-
+ if (isFirefox) {
33-
+ // Firefox doesn't support observing style tag contents
34-
+ // As a workaround, also observe the data-version attribute that is updated when the content is updated
35-
+ observeInit = { ...observeInit, attributes: true, attributeFilter: ['data-version'] };
36-
+ }
37-
+
38-
+ disposables.add(sharedMutationObserver.observe(globalStylesheet, disposables, observeInit)(() => {
20+
+ disposables.add(sharedMutationObserver.observe(globalStylesheet, disposables, { childList: true, subtree: true, characterData: true })(() => {
3921
clone.textContent = globalStylesheet.textContent;
4022
}));
4123

42-
diff --git a/src/vs/workbench/services/themes/browser/workbenchThemeService.ts b/src/vs/workbench/services/themes/browser/workbenchThemeService.ts
43-
index a9dc7c145e0..1f1dc89e3a2 100644
44-
--- a/src/vs/workbench/services/themes/browser/workbenchThemeService.ts
45-
+++ b/src/vs/workbench/services/themes/browser/workbenchThemeService.ts
46-
@@ -33,7 +33,7 @@ import { updateColorThemeConfigurationSchemas, updateFileIconThemeConfigurationS
47-
import { ProductIconThemeData, DEFAULT_PRODUCT_ICON_THEME_ID } from './productIconThemeData.js';
48-
import { registerProductIconThemeSchemas } from '../common/productIconThemeSchema.js';
49-
import { ILogService } from '../../../../platform/log/common/log.js';
50-
-import { isWeb } from '../../../../base/common/platform.js';
51-
+import { isFirefox, isWeb } from '../../../../base/common/platform.js';
52-
import { ColorScheme, ThemeTypeSelector } from '../../../../platform/theme/common/theme.js';
53-
import { IHostColorSchemeService } from '../common/hostColorSchemeService.js';
54-
import { RunOnceScheduler, Sequencer } from '../../../../base/common/async.js';
55-
@@ -793,13 +793,20 @@ class ThemeFileWatcher {
56-
}
57-
58-
function _applyRules(styleSheetContent: string, rulesClassName: string) {
59-
- const themeStyles = mainWindow.document.head.querySelectorAll(`.${rulesClassName}`);
60-
- if (themeStyles.length === 0) {
61-
- const elStyle = createStyleSheet();
62-
- elStyle.className = rulesClassName;
63-
- elStyle.textContent = styleSheetContent;
64-
- } else {
65-
- (<HTMLStyleElement>themeStyles[0]).textContent = styleSheetContent;
66-
+ let themeStyle = mainWindow.document.head.querySelector(`.${rulesClassName}`);
67-
+ if (!themeStyle) {
68-
+ themeStyle = createStyleSheet();
69-
+ themeStyle.className = rulesClassName;
70-
+ }
71-
+
72-
+ if (themeStyle.textContent !== styleSheetContent) {
73-
+ themeStyle.textContent = styleSheetContent;
74-
+
75-
+ if (isFirefox) {
76-
+ // Firefox doesn't support observing style tag contents
77-
+ // As a workaround, also update the data-version attribute when it changes so it can be observed
78-
+ themeStyle.setAttribute('data-version', crypto.randomUUID());
79-
+ }
80-
}
81-
}
82-

0 commit comments

Comments
 (0)