@opensumi/ide-editor 2.27.3-next-1710834527.0 → 2.27.3-next-1710917566.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/lib/browser/diff/compare.d.ts.map +1 -1
- package/lib/browser/diff/compare.js +0 -12
- package/lib/browser/diff/compare.js.map +1 -1
- package/lib/browser/doc-model/editor-document-model.d.ts.map +1 -1
- package/lib/browser/doc-model/editor-document-model.js +1 -1
- package/lib/browser/doc-model/editor-document-model.js.map +1 -1
- package/lib/browser/editor.contribution.d.ts +2 -0
- package/lib/browser/editor.contribution.d.ts.map +1 -1
- package/lib/browser/editor.contribution.js +34 -0
- package/lib/browser/editor.contribution.js.map +1 -1
- package/lib/browser/editor.module.less +49 -3
- package/lib/browser/merge-editor/MergeEditorFloatComponents.d.ts.map +1 -1
- package/lib/browser/merge-editor/MergeEditorFloatComponents.js +60 -1
- package/lib/browser/merge-editor/MergeEditorFloatComponents.js.map +1 -1
- package/lib/browser/merge-editor/merge-editor.contribution.d.ts +0 -1
- package/lib/browser/merge-editor/merge-editor.contribution.d.ts.map +1 -1
- package/lib/browser/merge-editor/merge-editor.contribution.js +2 -6
- package/lib/browser/merge-editor/merge-editor.contribution.js.map +1 -1
- package/lib/browser/workbench-editor.service.d.ts.map +1 -1
- package/lib/browser/workbench-editor.service.js +3 -0
- package/lib/browser/workbench-editor.service.js.map +1 -1
- package/package.json +13 -13
- package/src/browser/diff/compare.ts +0 -12
- package/src/browser/doc-model/editor-document-model.ts +2 -1
- package/src/browser/editor.contribution.ts +36 -0
- package/src/browser/editor.module.less +49 -3
- package/src/browser/merge-editor/MergeEditorFloatComponents.tsx +101 -4
- package/src/browser/merge-editor/merge-editor.contribution.ts +4 -8
- package/src/browser/workbench-editor.service.ts +2 -0
|
@@ -1,11 +1,14 @@
|
|
|
1
|
-
import React, { useCallback } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
|
-
import { Button } from '@opensumi/ide-components';
|
|
3
|
+
import { Button, Icon } from '@opensumi/ide-components';
|
|
4
4
|
import {
|
|
5
|
+
AINativeConfigService,
|
|
5
6
|
CommandRegistry,
|
|
6
7
|
CommandService,
|
|
8
|
+
IContextKeyService,
|
|
7
9
|
SCM_COMMANDS,
|
|
8
10
|
URI,
|
|
11
|
+
Uri,
|
|
9
12
|
localize,
|
|
10
13
|
useInjectable,
|
|
11
14
|
} from '@opensumi/ide-core-browser';
|
|
@@ -14,9 +17,31 @@ import styles from '../editor.module.less';
|
|
|
14
17
|
import { ReactEditorComponent } from '../types';
|
|
15
18
|
|
|
16
19
|
export const MergeEditorFloatComponents: ReactEditorComponent<{ uri: URI }> = ({ resource }) => {
|
|
20
|
+
const aiNativeConfigService = useInjectable<AINativeConfigService>(AINativeConfigService);
|
|
17
21
|
const commandService = useInjectable<CommandService>(CommandService);
|
|
18
22
|
const commandRegistry = useInjectable<CommandRegistry>(CommandRegistry);
|
|
23
|
+
const contextKeyService = useInjectable<IContextKeyService>(IContextKeyService);
|
|
19
24
|
|
|
25
|
+
const [isVisiable, setIsVisiable] = useState(false);
|
|
26
|
+
|
|
27
|
+
const gitMergeChangesSet = new Set(['git.mergeChanges']);
|
|
28
|
+
|
|
29
|
+
useEffect(() => {
|
|
30
|
+
const run = () => {
|
|
31
|
+
const mergeChanges = contextKeyService.getValue<Uri[]>('git.mergeChanges') || [];
|
|
32
|
+
setIsVisiable(mergeChanges.some((value) => value.toString() === resource.uri.toString()));
|
|
33
|
+
};
|
|
34
|
+
|
|
35
|
+
const disposed = contextKeyService.onDidChangeContext(({ payload }) => {
|
|
36
|
+
if (payload.affectsSome(gitMergeChangesSet)) {
|
|
37
|
+
run();
|
|
38
|
+
}
|
|
39
|
+
});
|
|
40
|
+
run();
|
|
41
|
+
return () => disposed.dispose();
|
|
42
|
+
}, [resource]);
|
|
43
|
+
|
|
44
|
+
const [isAiResolving, setIsAiResolving] = useState(false);
|
|
20
45
|
const handleOpenMergeEditor = useCallback(async () => {
|
|
21
46
|
const { uri } = resource;
|
|
22
47
|
|
|
@@ -27,11 +52,83 @@ export const MergeEditorFloatComponents: ReactEditorComponent<{ uri: URI }> = ({
|
|
|
27
52
|
});
|
|
28
53
|
}, [resource]);
|
|
29
54
|
|
|
55
|
+
const isSupportAiResolve = useCallback(
|
|
56
|
+
() => aiNativeConfigService.capabilities.supportsConflictResolve,
|
|
57
|
+
[aiNativeConfigService],
|
|
58
|
+
);
|
|
59
|
+
|
|
60
|
+
const handlePrev = () => {
|
|
61
|
+
commandService.tryExecuteCommand('merge-conflict.previous');
|
|
62
|
+
};
|
|
63
|
+
|
|
64
|
+
const handleNext = () => {
|
|
65
|
+
commandService.tryExecuteCommand('merge-conflict.next');
|
|
66
|
+
};
|
|
67
|
+
|
|
68
|
+
const handleAIResolve = useCallback(async () => {
|
|
69
|
+
setIsAiResolving(true);
|
|
70
|
+
if (isAiResolving) {
|
|
71
|
+
await commandService.executeCommand('merge-conflict.ai.all-accept-stop', resource.uri);
|
|
72
|
+
} else {
|
|
73
|
+
await commandService.executeCommand('merge-conflict.ai.all-accept', resource.uri);
|
|
74
|
+
}
|
|
75
|
+
setIsAiResolving(false);
|
|
76
|
+
}, [resource, isAiResolving]);
|
|
77
|
+
|
|
78
|
+
const handleReset = useCallback(() => {
|
|
79
|
+
commandService.executeCommand('merge-conflict.ai.all-reset', resource.uri);
|
|
80
|
+
}, [resource]);
|
|
81
|
+
|
|
82
|
+
if (!isVisiable) {
|
|
83
|
+
return null;
|
|
84
|
+
}
|
|
85
|
+
|
|
30
86
|
return (
|
|
31
87
|
<div className={styles.merge_editor_float_container}>
|
|
32
|
-
<
|
|
33
|
-
{
|
|
88
|
+
<div id='merge.editor.action.button.accept'>
|
|
89
|
+
<Button className={styles.merge_conflict_bottom_btn} size='large' onClick={handlePrev}>
|
|
90
|
+
<Icon icon={'left'} />
|
|
91
|
+
<span>{localize('mergeEditor.conflict.prev')}</span>
|
|
92
|
+
</Button>
|
|
93
|
+
<Button className={styles.merge_conflict_bottom_btn} size='large' onClick={handleNext}>
|
|
94
|
+
<span>{localize('mergeEditor.conflict.next')}</span>
|
|
95
|
+
<Icon icon={'right'} />
|
|
96
|
+
</Button>
|
|
97
|
+
</div>
|
|
98
|
+
<span className={styles.line_vertical}></span>
|
|
99
|
+
<Button
|
|
100
|
+
id='merge.editor.open.tradition'
|
|
101
|
+
className={styles.merge_conflict_bottom_btn}
|
|
102
|
+
size='large'
|
|
103
|
+
onClick={handleOpenMergeEditor}
|
|
104
|
+
>
|
|
105
|
+
<Icon icon={'swap'} />
|
|
106
|
+
<span>{localize('mergeEditor.open.3way')}</span>
|
|
107
|
+
</Button>
|
|
108
|
+
<Button id='merge.editor.rest' className={styles.merge_conflict_bottom_btn} size='large' onClick={handleReset}>
|
|
109
|
+
<Icon icon={'discard'} />
|
|
110
|
+
<span>{localize('mergeEditor.reset')}</span>
|
|
34
111
|
</Button>
|
|
112
|
+
{isSupportAiResolve() && (
|
|
113
|
+
<Button
|
|
114
|
+
id='merge.editor.conflict.resolve.all'
|
|
115
|
+
size='large'
|
|
116
|
+
className={`${styles.merge_conflict_bottom_btn} ${styles.magic_btn}`}
|
|
117
|
+
onClick={handleAIResolve}
|
|
118
|
+
>
|
|
119
|
+
{isAiResolving ? (
|
|
120
|
+
<>
|
|
121
|
+
<Icon icon={'circle-pause'} />
|
|
122
|
+
<span>{localize('mergeEditor.conflict.resolve.all.stop')}</span>
|
|
123
|
+
</>
|
|
124
|
+
) : (
|
|
125
|
+
<>
|
|
126
|
+
<Icon icon={'magic-wand'} />
|
|
127
|
+
<span>{localize('mergeEditor.conflict.resolve.all')}</span>
|
|
128
|
+
</>
|
|
129
|
+
)}
|
|
130
|
+
</Button>
|
|
131
|
+
)}
|
|
35
132
|
</div>
|
|
36
133
|
);
|
|
37
134
|
};
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Autowired } from '@opensumi/di';
|
|
2
|
-
import { Disposable, Domain,
|
|
2
|
+
import { Disposable, Domain, Schemes } from '@opensumi/ide-core-browser';
|
|
3
3
|
|
|
4
4
|
import { ResourceService } from '../../common';
|
|
5
5
|
import { BrowserEditorContribution, EditorComponentRegistry, EditorOpenType } from '../types';
|
|
@@ -14,9 +14,6 @@ export class MergeEditorContribution extends Disposable implements BrowserEditor
|
|
|
14
14
|
@Autowired()
|
|
15
15
|
private readonly mergeEditorResourceProvider: MergeEditorResourceProvider;
|
|
16
16
|
|
|
17
|
-
@Autowired(IContextKeyService)
|
|
18
|
-
private readonly contextKeyService: IContextKeyService;
|
|
19
|
-
|
|
20
17
|
registerResource(resourceService: ResourceService): void {
|
|
21
18
|
resourceService.registerResourceProvider(this.mergeEditorResourceProvider);
|
|
22
19
|
}
|
|
@@ -30,15 +27,14 @@ export class MergeEditorContribution extends Disposable implements BrowserEditor
|
|
|
30
27
|
|
|
31
28
|
registry.registerEditorSideWidget({
|
|
32
29
|
id: MERGE_EDITOR_FLOATING_WIDGET,
|
|
33
|
-
component: MergeEditorFloatComponents
|
|
30
|
+
component: MergeEditorFloatComponents,
|
|
34
31
|
displaysOnResource: (resource) => {
|
|
35
32
|
const { uri } = resource;
|
|
36
33
|
if (uri.scheme !== Schemes.file) {
|
|
37
34
|
return false;
|
|
38
35
|
}
|
|
39
|
-
|
|
40
|
-
|
|
41
|
-
return mergeChanges.some((value) => value.toString() === uri.toString());
|
|
36
|
+
// 由于存在时序问题,具体是否显示的逻辑由组件内部处理
|
|
37
|
+
return true;
|
|
42
38
|
},
|
|
43
39
|
});
|
|
44
40
|
}
|
|
@@ -1503,6 +1503,8 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1503
1503
|
const query = uri.getParsedQuery();
|
|
1504
1504
|
this.doDisposeDocRef(new URI(query.original));
|
|
1505
1505
|
this.doDisposeDocRef(new URI(query.modified));
|
|
1506
|
+
} else if (uri.scheme === 'mergeEditor') {
|
|
1507
|
+
this.mergeEditor.dispose();
|
|
1506
1508
|
} else {
|
|
1507
1509
|
this.doDisposeDocRef(uri);
|
|
1508
1510
|
}
|