Skip to content

Commit c165c9a

Browse files
author
guqiankun.gqk
committed
chore: 修复组件卸载问题
1 parent 3c8549d commit c165c9a

7 files changed

Lines changed: 26 additions & 13 deletions

File tree

packages/core/src/client/index.ts

Lines changed: 8 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,7 @@ import {
77
PreferenceProviderProvider,
88
PreferenceScope,
99
PreferenceProvider,
10+
IContextKeyService,
1011
} from '@opensumi/ide-core-browser';
1112
import { ClientApp as BasicClientApp } from '@opensumi/ide-core-browser/lib/bootstrap/app';
1213

@@ -56,6 +57,7 @@ import {
5657
MonacoCodeService,
5758
monacoCodeServiceProxy,
5859
} from './override/monacoOverride/codeEditorService';
60+
import { MonacoContextKeyServiceOverride } from './override/monacoOverride/contextKeyService';
5961

6062
// import { MonacoOverrides } from './override/monacoOverride';
6163
export * from './override/monacoOverride/codeEditorService';
@@ -128,6 +130,11 @@ export class ClientModule extends BrowserModule {
128130
token: IMonacoOverrideService,
129131
useClass: MonacoOverrideService,
130132
},
133+
{
134+
token: IContextKeyService,
135+
useClass: MonacoContextKeyServiceOverride,
136+
override: true,
137+
},
131138
];
132139
preferences = injectDebugPreferences;
133140
}
@@ -140,6 +147,7 @@ export { IClientAppOpts };
140147
// 先 dispose,待 opensumi 修复
141148
// @ts-ignore
142149
export class ClientApp extends BasicClientApp {
150+
private disposeSideEffect = () => {};
143151

144152
private modules: ModuleConstructor[] = [];
145153

packages/core/src/client/override/monacoContextKeyService.ts

Lines changed: 7 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -3,6 +3,7 @@ import {
33
MonacoContribution,
44
Domain,
55
MonacoOverrideServiceRegistry,
6+
IContextKeyService,
67
} from '@opensumi/ide-core-browser';
78
import { StandaloneKeybindingServiceProxy } from './monacoOverride/standaloneKeybindingService';
89

@@ -16,18 +17,21 @@ export const IMonacoOverrideService = Symbol('IMonacoOverrideService');
1617
@Domain(MonacoContribution)
1718
export class MonacoOverrideService implements MonacoContribution {
1819
@Autowired(ICommandServiceToken)
19-
monacoCommandService: MonacoCommandService;
20+
private monacoCommandService: MonacoCommandService;
2021

2122
@Autowired(MonacoCodeService)
22-
monacoCodeService: MonacoCodeService;
23+
private monacoCodeService: MonacoCodeService;
24+
25+
@Autowired(IContextKeyService)
26+
private readonly globalContextKeyService: IContextKeyService;
2327

2428
registerOverrideService(registry: MonacoOverrideServiceRegistry) {
2529

2630
// TODO opensumi ServiceNames
2731
registry.registerOverrideService(
2832
// @ts-ignore
2933
'keybindingService',
30-
new StandaloneKeybindingServiceProxy(this.monacoCodeService, this.monacoCommandService)
34+
new StandaloneKeybindingServiceProxy(this.globalContextKeyService.contextKeyService, this.monacoCodeService, this.monacoCommandService)
3135
);
3236
}
3337
}

packages/core/src/client/override/monacoOverride/contextKeyService.ts

Lines changed: 2 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -209,8 +209,9 @@ export class MonacoContextKeyServiceOverride
209209

210210
constructor() {
211211
super();
212-
this.contextKeyService = new ContextKeyService(this.configurationService);
212+
this.contextKeyService = (window as any).contextService || new ContextKeyService(this.configurationService);
213213
this.listenToContextChanges();
214+
(window as any).contextService = this.contextKeyService
214215
}
215216

216217
dispose(): void {

packages/core/src/client/override/monacoOverride/standaloneKeybindingService.ts

Lines changed: 4 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -1,17 +1,18 @@
11
import { ICommandService } from '@opensumi/monaco-editor-core/esm/vs/platform/commands/common/commands';
22
import { StandaloneKeybindingService } from '@opensumi/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
33
import { StandaloneServices } from '@opensumi/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
4-
import { IContextKeyService } from '@opensumi/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
4+
import { IContextKeyService as IMonacoContextKeyService } from '@opensumi/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
55
import { ITelemetryService } from '@opensumi/monaco-editor-core/esm/vs/platform/telemetry/common/telemetry';
66
import { INotificationService } from '@opensumi/monaco-editor-core/esm/vs/platform/notification/common/notification';
77
import { ILogService } from '@opensumi/monaco-editor-core/esm/vs/platform/log/common/log';
88
import { ICodeEditorService } from '@opensumi/monaco-editor-core/esm/vs/editor/browser/services/codeEditorService';
99

1010
export class StandaloneKeybindingServiceProxy extends StandaloneKeybindingService {
1111
// TODO contextService
12-
constructor(monacoCodeService: ICodeEditorService, monacoCommandService: ICommandService) {
12+
constructor(contextkeyService: IMonacoContextKeyService ,monacoCodeService: ICodeEditorService, monacoCommandService: ICommandService) {
1313
super(
14-
StandaloneServices.get(IContextKeyService),
14+
contextkeyService,
15+
// StandaloneServices.get(IContextKeyService),
1516
monacoCommandService,
1617
// StandaloneServices.get(ICommandService),
1718
StandaloneServices.get(ITelemetryService),

packages/integrations/src/sql/index.tsx

Lines changed: 2 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -122,10 +122,9 @@ const App = () => {
122122
setCurrent(e.key);
123123
// 每次切换tab 打开对应的文件
124124
if(e.key === '1') {
125-
SQLPlugin.api.commands?.executeCommand('alex.sql.open', 'test_uri1/test.sql');
125+
SQLPlugin.api.commands?.executeCommand('alex.sql.open', 'test_uri1/test.sql', '');
126126
}else {
127-
SQLPlugin.api.commands?.executeCommand('alex.sql.open', 'test_uri2/test.sql');
128-
127+
SQLPlugin.api.commands?.executeCommand('alex.sql.open', 'test_uri3/test.sql');
129128
}
130129
};
131130

packages/integrations/src/startup/index.tsx

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -84,7 +84,7 @@ if (pathParts[2]) {
8484
config.refPath = pathParts.slice(3).join('/');
8585

8686
const App = () => (
87-
<AppRenderer2
87+
<AppRenderer
8888
onLoad={(app) => {
8989
window.app = app;
9090
window.testPlugin = () => {

packages/toolkit/public/index.html

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -12,8 +12,8 @@
1212
margin: 0;
1313
}
1414
#main {
15-
/* width: 100vw;
16-
height: 100vh; */
15+
width: 100vw;
16+
height: 100vh;
1717
margin: 0;
1818
padding: 0;
1919
overflow: hidden;

0 commit comments

Comments
 (0)