@opensumi/ide-editor 3.1.2-next-1718957810.0 → 3.1.2
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/component.js.map +1 -1
- package/lib/browser/editor-collection.service.d.ts +0 -3
- package/lib/browser/editor-collection.service.d.ts.map +1 -1
- package/lib/browser/editor-collection.service.js +2 -14
- package/lib/browser/editor-collection.service.js.map +1 -1
- package/lib/browser/fs-resource/fs-editor-doc.d.ts.map +1 -1
- package/lib/browser/fs-resource/fs-editor-doc.js +0 -1
- package/lib/browser/fs-resource/fs-editor-doc.js.map +1 -1
- package/lib/browser/fs-resource/fs-resource.d.ts.map +1 -1
- package/lib/browser/fs-resource/fs-resource.js +1 -0
- package/lib/browser/fs-resource/fs-resource.js.map +1 -1
- package/lib/browser/merge-conflict/types.d.ts +17 -0
- package/lib/browser/merge-conflict/types.d.ts.map +1 -1
- package/lib/browser/merge-conflict/types.js +6 -1
- package/lib/browser/merge-conflict/types.js.map +1 -1
- package/lib/browser/merge-editor/MergeEditorFloatComponents.d.ts.map +1 -1
- package/lib/browser/merge-editor/MergeEditorFloatComponents.js +40 -7
- package/lib/browser/merge-editor/MergeEditorFloatComponents.js.map +1 -1
- package/lib/browser/tab.view.d.ts.map +1 -1
- package/lib/browser/tab.view.js +1 -1
- package/lib/browser/tab.view.js.map +1 -1
- package/lib/browser/types.d.ts +2 -2
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/types.js.map +1 -1
- package/lib/browser/workbench-editor.service.d.ts.map +1 -1
- package/lib/browser/workbench-editor.service.js +12 -9
- package/lib/browser/workbench-editor.service.js.map +1 -1
- package/lib/common/editor.d.ts +0 -1
- package/lib/common/editor.d.ts.map +1 -1
- package/lib/common/editor.js.map +1 -1
- package/package.json +14 -14
- package/src/browser/component.ts +1 -1
- package/src/browser/editor-collection.service.ts +2 -18
- package/src/browser/fs-resource/fs-editor-doc.ts +0 -4
- package/src/browser/fs-resource/fs-resource.ts +1 -0
- package/src/browser/merge-conflict/types.ts +21 -0
- package/src/browser/merge-editor/MergeEditorFloatComponents.tsx +45 -10
- package/src/browser/preference/schema.ts +1 -1
- package/src/browser/tab.view.tsx +0 -1
- package/src/browser/types.ts +6 -3
- package/src/browser/workbench-editor.service.ts +13 -9
- package/src/common/editor.ts +0 -2
- package/lib/browser/merge-conflict/merge-conflict.model.d.ts +0 -7
- package/lib/browser/merge-conflict/merge-conflict.model.d.ts.map +0 -1
- package/lib/browser/merge-conflict/merge-conflict.model.js +0 -51
- package/lib/browser/merge-conflict/merge-conflict.model.js.map +0 -1
- package/lib/browser/merge-conflict/merge-conflict.service.d.ts +0 -14
- package/lib/browser/merge-conflict/merge-conflict.service.d.ts.map +0 -1
- package/lib/browser/merge-conflict/merge-conflict.service.js +0 -66
- package/lib/browser/merge-conflict/merge-conflict.service.js.map +0 -1
- package/src/browser/merge-conflict/merge-conflict.model.ts +0 -63
- package/src/browser/merge-conflict/merge-conflict.service.ts +0 -65
package/package.json
CHANGED
|
@@ -1,6 +1,6 @@
|
|
|
1
1
|
{
|
|
2
2
|
"name": "@opensumi/ide-editor",
|
|
3
|
-
"version": "3.1.2
|
|
3
|
+
"version": "3.1.2",
|
|
4
4
|
"files": [
|
|
5
5
|
"lib",
|
|
6
6
|
"src"
|
|
@@ -17,21 +17,21 @@
|
|
|
17
17
|
"url": "git@github.com:opensumi/core.git"
|
|
18
18
|
},
|
|
19
19
|
"dependencies": {
|
|
20
|
-
"@opensumi/ide-core-common": "3.1.2
|
|
21
|
-
"@opensumi/ide-core-node": "3.1.2
|
|
22
|
-
"@opensumi/ide-file-service": "3.1.2
|
|
23
|
-
"@opensumi/ide-monaco": "3.1.2
|
|
24
|
-
"@opensumi/ide-utils": "3.1.2
|
|
20
|
+
"@opensumi/ide-core-common": "3.1.2",
|
|
21
|
+
"@opensumi/ide-core-node": "3.1.2",
|
|
22
|
+
"@opensumi/ide-file-service": "3.1.2",
|
|
23
|
+
"@opensumi/ide-monaco": "3.1.2",
|
|
24
|
+
"@opensumi/ide-utils": "3.1.2",
|
|
25
25
|
"vscode-oniguruma": "1.5.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@opensumi/ide-components": "3.1.2
|
|
29
|
-
"@opensumi/ide-core-browser": "3.1.2
|
|
30
|
-
"@opensumi/ide-dev-tool": "3.1.2
|
|
31
|
-
"@opensumi/ide-overlay": "3.1.2
|
|
32
|
-
"@opensumi/ide-quick-open": "3.1.2
|
|
33
|
-
"@opensumi/ide-theme": "3.1.2
|
|
34
|
-
"@opensumi/ide-workspace": "3.1.2
|
|
28
|
+
"@opensumi/ide-components": "3.1.2",
|
|
29
|
+
"@opensumi/ide-core-browser": "3.1.2",
|
|
30
|
+
"@opensumi/ide-dev-tool": "3.1.2",
|
|
31
|
+
"@opensumi/ide-overlay": "3.1.2",
|
|
32
|
+
"@opensumi/ide-quick-open": "3.1.2",
|
|
33
|
+
"@opensumi/ide-theme": "3.1.2",
|
|
34
|
+
"@opensumi/ide-workspace": "3.1.2"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "43ba89b95907f75c9f62880064bd0edb1d09ad7d"
|
|
37
37
|
}
|
package/src/browser/component.ts
CHANGED
|
@@ -108,7 +108,7 @@ export class EditorComponentRegistryImpl implements EditorComponentRegistry {
|
|
|
108
108
|
let results: IEditorOpenType[] = [];
|
|
109
109
|
const resolvers = this.getResolvers(resource.uri.scheme).slice(); // 防止异步操作时数组被改变
|
|
110
110
|
let shouldBreak = false;
|
|
111
|
-
const resolve = (res
|
|
111
|
+
const resolve = (res) => {
|
|
112
112
|
results = res;
|
|
113
113
|
shouldBreak = true;
|
|
114
114
|
};
|
|
@@ -562,8 +562,6 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
562
562
|
|
|
563
563
|
private modifiedDocModelRef: IEditorDocumentModelRef | null;
|
|
564
564
|
|
|
565
|
-
private diffEditorModelCache = new LRUCache<string, monaco.editor.IDiffEditorViewModel>(100);
|
|
566
|
-
|
|
567
565
|
get originalDocModel() {
|
|
568
566
|
if (this.originalDocModelRef && !this.originalDocModelRef.disposed) {
|
|
569
567
|
return this.originalDocModelRef.instance;
|
|
@@ -602,10 +600,6 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
602
600
|
|
|
603
601
|
private diffResourceKeys: ResourceContextKey[];
|
|
604
602
|
|
|
605
|
-
private _onRefOpen = new Emitter<IEditorDocumentModelRef>();
|
|
606
|
-
|
|
607
|
-
public onRefOpen = this._onRefOpen.event;
|
|
608
|
-
|
|
609
603
|
protected saveCurrentState() {
|
|
610
604
|
if (this.currentUri) {
|
|
611
605
|
const state = this.monacoDiffEditor.saveViewState();
|
|
@@ -651,13 +645,7 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
651
645
|
}
|
|
652
646
|
const original = this.originalDocModel.getMonacoModel();
|
|
653
647
|
const modified = this.modifiedDocModel.getMonacoModel();
|
|
654
|
-
const
|
|
655
|
-
let model = this.diffEditorModelCache.get(key);
|
|
656
|
-
if (!model || (model as any)._store.isDisposed) {
|
|
657
|
-
model = this.monacoDiffEditor.createViewModel({ original, modified });
|
|
658
|
-
this.diffEditorModelCache.set(key, model);
|
|
659
|
-
}
|
|
660
|
-
|
|
648
|
+
const model = this.monacoDiffEditor.createViewModel({ original, modified });
|
|
661
649
|
this.monacoDiffEditor.setModel(model);
|
|
662
650
|
|
|
663
651
|
if (rawUri) {
|
|
@@ -666,7 +654,6 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
666
654
|
this.currentUri = URI.from({
|
|
667
655
|
scheme: DIFF_SCHEME,
|
|
668
656
|
query: URI.stringifyQuery({
|
|
669
|
-
name,
|
|
670
657
|
original: this.originalDocModel!.uri.toString(),
|
|
671
658
|
modified: this.modifiedDocModel!.uri.toString(),
|
|
672
659
|
}),
|
|
@@ -676,6 +663,7 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
676
663
|
if (options.range || options.originalRange) {
|
|
677
664
|
const range = (options.range || options.originalRange) as monaco.IRange;
|
|
678
665
|
const currentEditor = options.range ? this.modifiedEditor.monacoEditor : this.originalEditor.monacoEditor;
|
|
666
|
+
await model?.waitForDiff();
|
|
679
667
|
// 必须使用 setTimeout, 因为两边的 editor 出现时机问题,diffEditor 是异步显示和渲染
|
|
680
668
|
setTimeout(() => {
|
|
681
669
|
currentEditor.revealRangeInCenter(range);
|
|
@@ -693,8 +681,6 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
693
681
|
} else {
|
|
694
682
|
this.restoreState();
|
|
695
683
|
}
|
|
696
|
-
this._onRefOpen.fire(originalDocModelRef);
|
|
697
|
-
this._onRefOpen.fire(modifiedDocModelRef);
|
|
698
684
|
const enableHideUnchanged = this.preferenceService.get('diffEditor.hideUnchangedRegions.enabled');
|
|
699
685
|
|
|
700
686
|
if (options.revealFirstDiff && !enableHideUnchanged) {
|
|
@@ -752,7 +738,6 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
752
738
|
}
|
|
753
739
|
|
|
754
740
|
updateDiffOptions() {
|
|
755
|
-
this.diffEditorModelCache.clear();
|
|
756
741
|
this.doUpdateDiffOptions();
|
|
757
742
|
}
|
|
758
743
|
|
|
@@ -822,7 +807,6 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
822
807
|
super.dispose();
|
|
823
808
|
this.collectionService.removeEditors([this.originalEditor, this.modifiedEditor]);
|
|
824
809
|
this.collectionService.removeDiffEditors([this]);
|
|
825
|
-
this.diffEditorModelCache.clear();
|
|
826
810
|
this.monacoDiffEditor.dispose();
|
|
827
811
|
this._disposed = true;
|
|
828
812
|
}
|
|
@@ -110,10 +110,7 @@ export class BaseFileSystemEditorDocumentProvider implements IEditorDocumentMode
|
|
|
110
110
|
uri.toString(),
|
|
111
111
|
getLanguageIdFromMonaco(uri)!,
|
|
112
112
|
);
|
|
113
|
-
|
|
114
|
-
// TODO: 应该挪到后端去做
|
|
115
113
|
const detected = await detectEncodingFromBuffer(buffer, guessEncoding);
|
|
116
|
-
|
|
117
114
|
detected.encoding = await this.getReadEncoding(uri, options, detected.encoding);
|
|
118
115
|
|
|
119
116
|
const content = buffer.toString(detected.encoding);
|
|
@@ -135,7 +132,6 @@ export class BaseFileSystemEditorDocumentProvider implements IEditorDocumentMode
|
|
|
135
132
|
// TODO: 这部分要优化成buffer获取(长期来看是stream获取,encoding在哪一层做?)
|
|
136
133
|
// 暂时还是使用 resolveContent 内提供的 decode 功能
|
|
137
134
|
// 之后 encoding 做了分层之后和其他的需要 decode 的地方一起改
|
|
138
|
-
|
|
139
135
|
return (await this.read(uri, { encoding })).content;
|
|
140
136
|
}
|
|
141
137
|
|
|
@@ -129,6 +129,7 @@ export class FileSystemResourceProvider extends WithEventBus implements IResourc
|
|
|
129
129
|
}
|
|
130
130
|
|
|
131
131
|
async provideResource(uri: URI): Promise<IResource<any>> {
|
|
132
|
+
// 获取文件类型 getFileType: (path: string) => string
|
|
132
133
|
await this.ready;
|
|
133
134
|
this.involvedFiles.add(uri.codeUri.fsPath);
|
|
134
135
|
return Promise.all([
|
|
@@ -41,6 +41,27 @@ export interface ICacheDocumentMergeConflict extends IDocumentMergeConflictDescr
|
|
|
41
41
|
aiContent?: string;
|
|
42
42
|
}
|
|
43
43
|
|
|
44
|
+
export interface IDocumentMergeConflictTracker {
|
|
45
|
+
getConflicts(document: monaco.editor.ITextModel): PromiseLike<IDocumentMergeConflict[]>;
|
|
46
|
+
isPending(document: monaco.editor.ITextModel): boolean;
|
|
47
|
+
forget(document: monaco.editor.ITextModel): void;
|
|
48
|
+
}
|
|
49
|
+
|
|
50
|
+
export interface IDocumentMergeConflictTrackerService {
|
|
51
|
+
createTracker(origin: string): IDocumentMergeConflictTracker;
|
|
52
|
+
forget(document: monaco.editor.ITextModel): void;
|
|
53
|
+
}
|
|
54
|
+
|
|
55
|
+
export interface IDocumentMergeConflictNavigationResults {
|
|
56
|
+
canNavigate: boolean;
|
|
57
|
+
conflict?: IDocumentMergeConflict;
|
|
58
|
+
}
|
|
59
|
+
|
|
60
|
+
export enum NavigationDirection {
|
|
61
|
+
Forwards,
|
|
62
|
+
Backwards,
|
|
63
|
+
}
|
|
64
|
+
|
|
44
65
|
export namespace AI_COMMAND {
|
|
45
66
|
const MERGE_CONFLICT = 'merge-conflict';
|
|
46
67
|
export const ACCEPT = `${MERGE_CONFLICT}.ai.accept`;
|
|
@@ -1,37 +1,72 @@
|
|
|
1
|
-
import React, { useCallback, useState } from 'react';
|
|
1
|
+
import React, { useCallback, useEffect, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
CommandRegistry,
|
|
5
5
|
CommandService,
|
|
6
|
+
DisposableStore,
|
|
6
7
|
MERGE_CONFLICT_COMMANDS,
|
|
7
8
|
SCM_COMMANDS,
|
|
8
9
|
URI,
|
|
9
10
|
useInjectable,
|
|
10
11
|
} from '@opensumi/ide-core-browser';
|
|
12
|
+
import { formatLocalize } from '@opensumi/ide-core-common';
|
|
13
|
+
import { MergeConflictCommands } from '@opensumi/ide-core-common/lib/commands/git';
|
|
11
14
|
import { MergeActions } from '@opensumi/ide-monaco/lib/browser/contrib/merge-editor/components/merge-actions';
|
|
12
15
|
|
|
13
|
-
import {
|
|
14
|
-
import {
|
|
16
|
+
import { useEditorDocumentModelRef } from '../hooks/useEditor';
|
|
17
|
+
import { DocumentMergeConflict, MergeConflictParser } from '../merge-conflict';
|
|
15
18
|
import { ReactEditorComponent } from '../types';
|
|
16
19
|
|
|
17
20
|
export const MergeEditorFloatComponents: ReactEditorComponent<{ uri: URI }> = ({ resource }) => {
|
|
18
21
|
const { uri } = resource;
|
|
19
|
-
const
|
|
22
|
+
const editorModel = useEditorDocumentModelRef(uri);
|
|
23
|
+
const mergeConflictParser: MergeConflictParser = useInjectable(MergeConflictParser);
|
|
20
24
|
const commandService = useInjectable<CommandService>(CommandService);
|
|
21
25
|
const commandRegistry = useInjectable<CommandRegistry>(CommandRegistry);
|
|
22
26
|
|
|
23
|
-
const
|
|
27
|
+
const [isVisiable, setIsVisiable] = useState(false);
|
|
28
|
+
const [conflicts, setConflicts] = useState<DocumentMergeConflict[]>([]);
|
|
24
29
|
|
|
25
|
-
|
|
30
|
+
useEffect(() => {
|
|
31
|
+
const disposables = new DisposableStore();
|
|
32
|
+
|
|
33
|
+
if (editorModel) {
|
|
34
|
+
const { instance } = editorModel;
|
|
35
|
+
const run = () => {
|
|
36
|
+
const conflicts = mergeConflictParser.scanDocument(instance.getMonacoModel());
|
|
37
|
+
if (conflicts.length > 0) {
|
|
38
|
+
setIsVisiable(true);
|
|
39
|
+
setConflicts(conflicts);
|
|
40
|
+
} else {
|
|
41
|
+
setIsVisiable(false);
|
|
42
|
+
setConflicts([]);
|
|
43
|
+
}
|
|
44
|
+
};
|
|
45
|
+
|
|
46
|
+
disposables.add(
|
|
47
|
+
editorModel.instance.getMonacoModel().onDidChangeContent(() => {
|
|
48
|
+
run();
|
|
49
|
+
}),
|
|
50
|
+
);
|
|
51
|
+
run();
|
|
52
|
+
return () => {
|
|
53
|
+
disposables.dispose();
|
|
54
|
+
};
|
|
55
|
+
}
|
|
56
|
+
}, [editorModel]);
|
|
26
57
|
|
|
58
|
+
const [isAIResolving, setIsAIResolving] = useState(false);
|
|
27
59
|
const handlePrev = useCallback(() => {
|
|
28
|
-
|
|
60
|
+
commandService.tryExecuteCommand(MergeConflictCommands.Previous).then(() => {
|
|
61
|
+
// TODO: 编辑器向上滚动一行
|
|
62
|
+
});
|
|
29
63
|
}, []);
|
|
30
64
|
|
|
31
65
|
const handleNext = useCallback(() => {
|
|
32
|
-
|
|
66
|
+
commandService.tryExecuteCommand(MergeConflictCommands.Next).then(() => {
|
|
67
|
+
// TODO: 编辑器向上滚动一行
|
|
68
|
+
});
|
|
33
69
|
}, []);
|
|
34
|
-
|
|
35
70
|
const handleAIResolve = useCallback(async () => {
|
|
36
71
|
setIsAIResolving(true);
|
|
37
72
|
if (isAIResolving) {
|
|
@@ -46,12 +81,12 @@ export const MergeEditorFloatComponents: ReactEditorComponent<{ uri: URI }> = ({
|
|
|
46
81
|
return null;
|
|
47
82
|
}
|
|
48
83
|
|
|
84
|
+
const summary = formatLocalize('merge-conflicts.merge.conflict.remain', conflicts.length);
|
|
49
85
|
return (
|
|
50
86
|
<MergeActions
|
|
51
87
|
uri={uri}
|
|
52
88
|
editorType='text'
|
|
53
89
|
summary={summary}
|
|
54
|
-
canNavigate={canNavigate}
|
|
55
90
|
handleNext={handleNext}
|
|
56
91
|
handlePrev={handlePrev}
|
|
57
92
|
isAIResolving={isAIResolving}
|
|
@@ -1631,7 +1631,7 @@ const customEditorSchema: PreferenceSchemaProperties = {
|
|
|
1631
1631
|
},
|
|
1632
1632
|
'editor.largeFile': {
|
|
1633
1633
|
type: 'number',
|
|
1634
|
-
default: 4 * 1024 * 1024 * 1024,
|
|
1634
|
+
default: 4 * 1024 * 1024 * 1024,
|
|
1635
1635
|
description: '%editor.configuration.largeFileSize%',
|
|
1636
1636
|
},
|
|
1637
1637
|
'editor.quickSuggestionsDelay': {
|
package/src/browser/tab.view.tsx
CHANGED
|
@@ -391,7 +391,6 @@ export const Tabs = ({ group }: ITabsProps) => {
|
|
|
391
391
|
const curTabIndex = group.resources.findIndex((resource) => group.currentResource === resource);
|
|
392
392
|
return (
|
|
393
393
|
<div
|
|
394
|
-
draggable={false}
|
|
395
394
|
className={cls({
|
|
396
395
|
[styles_kt_editor_tabs_content]: true,
|
|
397
396
|
[styles_kt_editor_tabs_current_last]: curTabIndex === group.resources.length - 1,
|
package/src/browser/types.ts
CHANGED
|
@@ -114,10 +114,13 @@ export class RegisterEditorComponentEvent extends BasicEvent<string> {}
|
|
|
114
114
|
export abstract class EditorComponentRegistry {
|
|
115
115
|
abstract registerEditorComponent<T>(component: IEditorComponent<T>, initialProps?: any): IDisposable;
|
|
116
116
|
|
|
117
|
+
// 等同于 handlesScheme => 10
|
|
118
|
+
abstract registerEditorComponentResolver<T>(scheme: string, resolver: IEditorComponentResolver<T>): IDisposable;
|
|
119
|
+
|
|
120
|
+
// handlesScheme 返回权重, 小于 0 表示不处理
|
|
117
121
|
abstract registerEditorComponentResolver<T>(
|
|
118
|
-
|
|
119
|
-
|
|
120
|
-
| ((scheme: string) => number), // handlesScheme 返回权重, 小于 0 表示不处理
|
|
122
|
+
// eslint-disable-next-line @typescript-eslint/unified-signatures
|
|
123
|
+
handlesScheme: (scheme: string) => number,
|
|
121
124
|
resolver: IEditorComponentResolver<T>,
|
|
122
125
|
): IDisposable;
|
|
123
126
|
|
|
@@ -1539,29 +1539,34 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1539
1539
|
}
|
|
1540
1540
|
|
|
1541
1541
|
async getDocumentModelRef(uri: URI): Promise<IEditorDocumentModelRef> {
|
|
1542
|
-
|
|
1542
|
+
const key = uri.toString();
|
|
1543
|
+
|
|
1544
|
+
if (!this.holdDocumentModelRefs.has(key)) {
|
|
1543
1545
|
this.holdDocumentModelRefs.set(
|
|
1544
|
-
|
|
1546
|
+
key,
|
|
1545
1547
|
await this.documentModelManager.createModelReference(uri, 'editor-group-' + this.name),
|
|
1546
1548
|
);
|
|
1547
1549
|
}
|
|
1548
|
-
return this.holdDocumentModelRefs.get(
|
|
1550
|
+
return this.holdDocumentModelRefs.get(key)!;
|
|
1549
1551
|
}
|
|
1550
1552
|
|
|
1551
1553
|
disposeDocumentRef(uri: URI) {
|
|
1552
1554
|
if (uri.scheme === 'diff') {
|
|
1553
|
-
|
|
1555
|
+
const query = uri.getParsedQuery();
|
|
1556
|
+
this.doDisposeDocRef(new URI(query.original));
|
|
1557
|
+
this.doDisposeDocRef(new URI(query.modified));
|
|
1554
1558
|
} else if (uri.scheme === 'mergeEditor') {
|
|
1555
|
-
this.mergeEditor.dispose();
|
|
1559
|
+
this.mergeEditor && this.mergeEditor.dispose();
|
|
1556
1560
|
} else {
|
|
1557
1561
|
this.doDisposeDocRef(uri);
|
|
1558
1562
|
}
|
|
1559
1563
|
}
|
|
1560
1564
|
|
|
1561
1565
|
protected doDisposeDocRef(uri: URI) {
|
|
1562
|
-
|
|
1563
|
-
|
|
1564
|
-
this.holdDocumentModelRefs.
|
|
1566
|
+
const key = uri.toString();
|
|
1567
|
+
if (this.holdDocumentModelRefs.has(key)) {
|
|
1568
|
+
this.holdDocumentModelRefs.get(key)!.dispose();
|
|
1569
|
+
this.holdDocumentModelRefs.delete(key);
|
|
1565
1570
|
}
|
|
1566
1571
|
}
|
|
1567
1572
|
|
|
@@ -1654,7 +1659,6 @@ export class EditorGroup extends WithEventBus implements IGridEditorGroup {
|
|
|
1654
1659
|
await this.diffEditor.compare(original, modified, options, resource.uri);
|
|
1655
1660
|
if (options.focus) {
|
|
1656
1661
|
this._domNode?.focus();
|
|
1657
|
-
// 理由见上方 codeEditor.focus 部分
|
|
1658
1662
|
|
|
1659
1663
|
const disposer = this.eventBus.on(CodeEditorDidVisibleEvent, (e) => {
|
|
1660
1664
|
if (e.payload.groupName === this.name && e.payload.type === EditorOpenType.diff) {
|
package/src/common/editor.ts
CHANGED
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-conflict.model.d.ts","sourceRoot":"","sources":["../../../src/browser/merge-conflict/merge-conflict.model.ts"],"names":[],"mappings":"AAIA,OAAO,EAAmB,GAAG,EAAE,MAAM,qBAAqB,CAAC;AAM3D,wBAAgB,qBAAqB,CAAC,GAAG,EAAE,GAAG;;;;EAoD7C"}
|
|
@@ -1,51 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.useMergeConflictModel = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const debounce_1 = tslib_1.__importDefault(require("lodash/debounce"));
|
|
6
|
-
const react_1 = require("react");
|
|
7
|
-
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
|
|
8
|
-
const ide_utils_1 = require("@opensumi/ide-utils");
|
|
9
|
-
const useEditor_1 = require("../hooks/useEditor");
|
|
10
|
-
const merge_conflict_service_1 = require("./merge-conflict.service");
|
|
11
|
-
function useMergeConflictModel(uri) {
|
|
12
|
-
const editorModel = (0, useEditor_1.useEditorDocumentModelRef)(uri);
|
|
13
|
-
/**
|
|
14
|
-
* 如果是原来就有冲突的文件,当冲突没了之后,仍然显示冲突
|
|
15
|
-
*/
|
|
16
|
-
const [isInitialVisiable, setIsInitialVisiable] = (0, react_1.useState)(false);
|
|
17
|
-
const [conflictsCount, setConflictsCount] = (0, react_1.useState)(0);
|
|
18
|
-
const mergeConflictService = (0, ide_core_browser_1.useInjectable)(merge_conflict_service_1.MergeConflictService);
|
|
19
|
-
const summary = (0, react_1.useMemo)(() => (0, ide_core_browser_1.formatLocalize)('merge-conflicts.merge.conflict.remain', conflictsCount), [conflictsCount]);
|
|
20
|
-
(0, react_1.useEffect)(() => {
|
|
21
|
-
const disposables = new ide_utils_1.DisposableStore();
|
|
22
|
-
if (editorModel) {
|
|
23
|
-
const { instance } = editorModel;
|
|
24
|
-
const run = () => {
|
|
25
|
-
const n = mergeConflictService.scanDocument(instance.getMonacoModel());
|
|
26
|
-
setConflictsCount(n);
|
|
27
|
-
if (n > 0) {
|
|
28
|
-
setIsInitialVisiable(true);
|
|
29
|
-
}
|
|
30
|
-
};
|
|
31
|
-
const debounceRun = (0, debounce_1.default)(run, 150);
|
|
32
|
-
disposables.add(instance.getMonacoModel().onDidChangeContent(() => {
|
|
33
|
-
debounceRun();
|
|
34
|
-
}));
|
|
35
|
-
run();
|
|
36
|
-
return () => {
|
|
37
|
-
disposables.dispose();
|
|
38
|
-
mergeConflictService.clear();
|
|
39
|
-
setIsInitialVisiable(false);
|
|
40
|
-
setConflictsCount(0);
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}, [editorModel]);
|
|
44
|
-
return {
|
|
45
|
-
isVisiable: isInitialVisiable,
|
|
46
|
-
summary,
|
|
47
|
-
canNavigate: conflictsCount > 0,
|
|
48
|
-
};
|
|
49
|
-
}
|
|
50
|
-
exports.useMergeConflictModel = useMergeConflictModel;
|
|
51
|
-
//# sourceMappingURL=merge-conflict.model.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-conflict.model.js","sourceRoot":"","sources":["../../../src/browser/merge-conflict/merge-conflict.model.ts"],"names":[],"mappings":";;;;AAAA,uEAAuC;AACvC,iCAAqD;AAErD,iEAA2E;AAC3E,mDAA2D;AAE3D,kDAA+D;AAE/D,qEAAgE;AAEhE,SAAgB,qBAAqB,CAAC,GAAQ;IAC5C,MAAM,WAAW,GAAG,IAAA,qCAAyB,EAAC,GAAG,CAAC,CAAC;IAEnD;;OAEG;IACH,MAAM,CAAC,iBAAiB,EAAE,oBAAoB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAClE,MAAM,CAAC,cAAc,EAAE,iBAAiB,CAAC,GAAG,IAAA,gBAAQ,EAAC,CAAC,CAAC,CAAC;IAExD,MAAM,oBAAoB,GAAG,IAAA,gCAAa,EAAuB,6CAAoB,CAAC,CAAC;IAEvF,MAAM,OAAO,GAAG,IAAA,eAAO,EACrB,GAAG,EAAE,CAAC,IAAA,iCAAc,EAAC,uCAAuC,EAAE,cAAc,CAAC,EAC7E,CAAC,cAAc,CAAC,CACjB,CAAC;IAEF,IAAA,iBAAS,EAAC,GAAG,EAAE;QACb,MAAM,WAAW,GAAG,IAAI,2BAAe,EAAE,CAAC;QAE1C,IAAI,WAAW,EAAE;YACf,MAAM,EAAE,QAAQ,EAAE,GAAG,WAAW,CAAC;YACjC,MAAM,GAAG,GAAG,GAAG,EAAE;gBACf,MAAM,CAAC,GAAG,oBAAoB,CAAC,YAAY,CAAC,QAAQ,CAAC,cAAc,EAAE,CAAC,CAAC;gBACvE,iBAAiB,CAAC,CAAC,CAAC,CAAC;gBACrB,IAAI,CAAC,GAAG,CAAC,EAAE;oBACT,oBAAoB,CAAC,IAAI,CAAC,CAAC;iBAC5B;YACH,CAAC,CAAC;YAEF,MAAM,WAAW,GAAG,IAAA,kBAAQ,EAAC,GAAG,EAAE,GAAG,CAAC,CAAC;YAEvC,WAAW,CAAC,GAAG,CACb,QAAQ,CAAC,cAAc,EAAE,CAAC,kBAAkB,CAAC,GAAG,EAAE;gBAChD,WAAW,EAAE,CAAC;YAChB,CAAC,CAAC,CACH,CAAC;YAEF,GAAG,EAAE,CAAC;YACN,OAAO,GAAG,EAAE;gBACV,WAAW,CAAC,OAAO,EAAE,CAAC;gBACtB,oBAAoB,CAAC,KAAK,EAAE,CAAC;gBAC7B,oBAAoB,CAAC,KAAK,CAAC,CAAC;gBAC5B,iBAAiB,CAAC,CAAC,CAAC,CAAC;YACvB,CAAC,CAAC;SACH;IACH,CAAC,EAAE,CAAC,WAAW,CAAC,CAAC,CAAC;IAElB,OAAO;QACL,UAAU,EAAE,iBAAiB;QAC7B,OAAO;QACP,WAAW,EAAE,cAAc,GAAG,CAAC;KAChC,CAAC;AACJ,CAAC;AApDD,sDAoDC"}
|
|
@@ -1,14 +0,0 @@
|
|
|
1
|
-
import * as monaco from '@opensumi/ide-monaco';
|
|
2
|
-
import { DocumentMergeConflict, MergeConflictParser } from './conflict-parser';
|
|
3
|
-
export declare class MergeConflictService {
|
|
4
|
-
parser: MergeConflictParser;
|
|
5
|
-
private readonly editorService;
|
|
6
|
-
private readonly messageService;
|
|
7
|
-
conflicts: DocumentMergeConflict[];
|
|
8
|
-
scanDocument(model: monaco.editor.ITextModel): number;
|
|
9
|
-
clear(): void;
|
|
10
|
-
private navigate;
|
|
11
|
-
navigateNext(): Promise<void>;
|
|
12
|
-
navigatePrevious(): Promise<void>;
|
|
13
|
-
}
|
|
14
|
-
//# sourceMappingURL=merge-conflict.service.d.ts.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-conflict.service.d.ts","sourceRoot":"","sources":["../../../src/browser/merge-conflict/merge-conflict.service.ts"],"names":[],"mappings":"AACA,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAM/C,OAAO,EAAE,qBAAqB,EAAE,mBAAmB,EAAE,MAAM,mBAAmB,CAAC;AAE/E,qBACa,oBAAoB;IAE/B,MAAM,EAAE,mBAAmB,CAAC;IAG5B,OAAO,CAAC,QAAQ,CAAC,aAAa,CAAyB;IAGvD,OAAO,CAAC,QAAQ,CAAC,cAAc,CAAkB;IAEjD,SAAS,0BAAiC;IAE1C,YAAY,CAAC,KAAK,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU;IAK5C,KAAK,IAAI,IAAI;YAIC,QAAQ;IA0BtB,YAAY,IAAI,OAAO,CAAC,IAAI,CAAC;IAI7B,gBAAgB,IAAI,OAAO,CAAC,IAAI,CAAC;CAGlC"}
|
|
@@ -1,66 +0,0 @@
|
|
|
1
|
-
"use strict";
|
|
2
|
-
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.MergeConflictService = void 0;
|
|
4
|
-
const tslib_1 = require("tslib");
|
|
5
|
-
const di_1 = require("@opensumi/di");
|
|
6
|
-
const merge_editor_1 = require("@opensumi/ide-monaco/lib/browser/contrib/merge-editor");
|
|
7
|
-
const ide_overlay_1 = require("@opensumi/ide-overlay");
|
|
8
|
-
const types_1 = require("../types");
|
|
9
|
-
const conflict_parser_1 = require("./conflict-parser");
|
|
10
|
-
let MergeConflictService = class MergeConflictService {
|
|
11
|
-
constructor() {
|
|
12
|
-
this.conflicts = [];
|
|
13
|
-
}
|
|
14
|
-
scanDocument(model) {
|
|
15
|
-
this.conflicts = this.parser.scanDocument(model);
|
|
16
|
-
return this.conflicts.length;
|
|
17
|
-
}
|
|
18
|
-
clear() {
|
|
19
|
-
this.conflicts = [];
|
|
20
|
-
}
|
|
21
|
-
async navigate(editor, direction) {
|
|
22
|
-
this.conflicts = this.parser.scanDocument(editor.monacoEditor.getModel());
|
|
23
|
-
const ranges = this.conflicts.map((conflict) => conflict.range);
|
|
24
|
-
const navigationResult = (0, merge_editor_1.findRangeForNavigation)(direction, ranges, editor.monacoEditor.getPosition());
|
|
25
|
-
if (!navigationResult) {
|
|
26
|
-
this.messageService.warning('No merge conflicts found in this file');
|
|
27
|
-
return;
|
|
28
|
-
}
|
|
29
|
-
else if (!navigationResult.canNavigate) {
|
|
30
|
-
this.messageService.warning('No other merge conflicts within this file');
|
|
31
|
-
return;
|
|
32
|
-
}
|
|
33
|
-
else if (!navigationResult.range) {
|
|
34
|
-
// impossible path
|
|
35
|
-
return;
|
|
36
|
-
}
|
|
37
|
-
editor.monacoEditor.setPosition(navigationResult.range.getStartPosition());
|
|
38
|
-
// when navigating, we want to show the codelens on the first line of the conflict
|
|
39
|
-
const range = navigationResult.range.delta(-1);
|
|
40
|
-
editor.monacoEditor.revealRangeNearTopIfOutsideViewport(range);
|
|
41
|
-
editor.monacoEditor.focus();
|
|
42
|
-
}
|
|
43
|
-
navigateNext() {
|
|
44
|
-
return this.navigate(this.editorService.currentEditor, merge_editor_1.NavigationDirection.Forwards);
|
|
45
|
-
}
|
|
46
|
-
navigatePrevious() {
|
|
47
|
-
return this.navigate(this.editorService.currentEditor, merge_editor_1.NavigationDirection.Backwards);
|
|
48
|
-
}
|
|
49
|
-
};
|
|
50
|
-
tslib_1.__decorate([
|
|
51
|
-
(0, di_1.Autowired)(conflict_parser_1.MergeConflictParser),
|
|
52
|
-
tslib_1.__metadata("design:type", conflict_parser_1.MergeConflictParser)
|
|
53
|
-
], MergeConflictService.prototype, "parser", void 0);
|
|
54
|
-
tslib_1.__decorate([
|
|
55
|
-
(0, di_1.Autowired)(types_1.WorkbenchEditorService),
|
|
56
|
-
tslib_1.__metadata("design:type", types_1.WorkbenchEditorService)
|
|
57
|
-
], MergeConflictService.prototype, "editorService", void 0);
|
|
58
|
-
tslib_1.__decorate([
|
|
59
|
-
(0, di_1.Autowired)(ide_overlay_1.IMessageService),
|
|
60
|
-
tslib_1.__metadata("design:type", Object)
|
|
61
|
-
], MergeConflictService.prototype, "messageService", void 0);
|
|
62
|
-
MergeConflictService = tslib_1.__decorate([
|
|
63
|
-
(0, di_1.Injectable)()
|
|
64
|
-
], MergeConflictService);
|
|
65
|
-
exports.MergeConflictService = MergeConflictService;
|
|
66
|
-
//# sourceMappingURL=merge-conflict.service.js.map
|
|
@@ -1 +0,0 @@
|
|
|
1
|
-
{"version":3,"file":"merge-conflict.service.js","sourceRoot":"","sources":["../../../src/browser/merge-conflict/merge-conflict.service.ts"],"names":[],"mappings":";;;;AAAA,qCAAqD;AAErD,wFAAoH;AACpH,uDAAwD;AAExD,oCAA2D;AAE3D,uDAA+E;AAGxE,IAAM,oBAAoB,GAA1B,MAAM,oBAAoB;IAA1B;QAUL,cAAS,GAAG,EAA6B,CAAC;IA4C5C,CAAC;IA1CC,YAAY,CAAC,KAA+B;QAC1C,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,KAAK,CAAC,CAAC;QACjD,OAAO,IAAI,CAAC,SAAS,CAAC,MAAM,CAAC;IAC/B,CAAC;IAED,KAAK;QACH,IAAI,CAAC,SAAS,GAAG,EAAE,CAAC;IACtB,CAAC;IAEO,KAAK,CAAC,QAAQ,CAAC,MAAe,EAAE,SAA8B;QACpE,IAAI,CAAC,SAAS,GAAG,IAAI,CAAC,MAAM,CAAC,YAAY,CAAC,MAAM,CAAC,YAAY,CAAC,QAAQ,EAAG,CAAC,CAAC;QAC3E,MAAM,MAAM,GAAG,IAAI,CAAC,SAAS,CAAC,GAAG,CAAC,CAAC,QAAQ,EAAE,EAAE,CAAC,QAAQ,CAAC,KAAK,CAAC,CAAC;QAEhE,MAAM,gBAAgB,GAAG,IAAA,qCAAsB,EAAC,SAAS,EAAE,MAAM,EAAE,MAAM,CAAC,YAAY,CAAC,WAAW,EAAG,CAAC,CAAC;QAEvG,IAAI,CAAC,gBAAgB,EAAE;YACrB,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,uCAAuC,CAAC,CAAC;YACrE,OAAO;SACR;aAAM,IAAI,CAAC,gBAAgB,CAAC,WAAW,EAAE;YACxC,IAAI,CAAC,cAAc,CAAC,OAAO,CAAC,2CAA2C,CAAC,CAAC;YACzE,OAAO;SACR;aAAM,IAAI,CAAC,gBAAgB,CAAC,KAAK,EAAE;YAClC,kBAAkB;YAClB,OAAO;SACR;QAED,MAAM,CAAC,YAAY,CAAC,WAAW,CAAC,gBAAgB,CAAC,KAAK,CAAC,gBAAgB,EAAE,CAAC,CAAC;QAE3E,kFAAkF;QAClF,MAAM,KAAK,GAAG,gBAAgB,CAAC,KAAK,CAAC,KAAK,CAAC,CAAC,CAAC,CAAC,CAAC;QAE/C,MAAM,CAAC,YAAY,CAAC,mCAAmC,CAAC,KAAK,CAAC,CAAC;QAC/D,MAAM,CAAC,YAAY,CAAC,KAAK,EAAE,CAAC;IAC9B,CAAC;IAED,YAAY;QACV,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,aAAc,EAAE,kCAAmB,CAAC,QAAQ,CAAC,CAAC;IACxF,CAAC;IAED,gBAAgB;QACd,OAAO,IAAI,CAAC,QAAQ,CAAC,IAAI,CAAC,aAAa,CAAC,aAAc,EAAE,kCAAmB,CAAC,SAAS,CAAC,CAAC;IACzF,CAAC;CACF,CAAA;AArDC;IAAC,IAAA,cAAS,EAAC,qCAAmB,CAAC;sCACvB,qCAAmB;oDAAC;AAE5B;IAAC,IAAA,cAAS,EAAC,8BAAsB,CAAC;sCACF,8BAAsB;2DAAC;AAEvD;IAAC,IAAA,cAAS,EAAC,6BAAe,CAAC;;4DACsB;AARtC,oBAAoB;IADhC,IAAA,eAAU,GAAE;GACA,oBAAoB,CAsDhC;AAtDY,oDAAoB"}
|
|
@@ -1,63 +0,0 @@
|
|
|
1
|
-
import debounce from 'lodash/debounce';
|
|
2
|
-
import { useEffect, useMemo, useState } from 'react';
|
|
3
|
-
|
|
4
|
-
import { formatLocalize, useInjectable } from '@opensumi/ide-core-browser';
|
|
5
|
-
import { DisposableStore, URI } from '@opensumi/ide-utils';
|
|
6
|
-
|
|
7
|
-
import { useEditorDocumentModelRef } from '../hooks/useEditor';
|
|
8
|
-
|
|
9
|
-
import { MergeConflictService } from './merge-conflict.service';
|
|
10
|
-
|
|
11
|
-
export function useMergeConflictModel(uri: URI) {
|
|
12
|
-
const editorModel = useEditorDocumentModelRef(uri);
|
|
13
|
-
|
|
14
|
-
/**
|
|
15
|
-
* 如果是原来就有冲突的文件,当冲突没了之后,仍然显示冲突
|
|
16
|
-
*/
|
|
17
|
-
const [isInitialVisiable, setIsInitialVisiable] = useState(false);
|
|
18
|
-
const [conflictsCount, setConflictsCount] = useState(0);
|
|
19
|
-
|
|
20
|
-
const mergeConflictService = useInjectable<MergeConflictService>(MergeConflictService);
|
|
21
|
-
|
|
22
|
-
const summary = useMemo(
|
|
23
|
-
() => formatLocalize('merge-conflicts.merge.conflict.remain', conflictsCount),
|
|
24
|
-
[conflictsCount],
|
|
25
|
-
);
|
|
26
|
-
|
|
27
|
-
useEffect(() => {
|
|
28
|
-
const disposables = new DisposableStore();
|
|
29
|
-
|
|
30
|
-
if (editorModel) {
|
|
31
|
-
const { instance } = editorModel;
|
|
32
|
-
const run = () => {
|
|
33
|
-
const n = mergeConflictService.scanDocument(instance.getMonacoModel());
|
|
34
|
-
setConflictsCount(n);
|
|
35
|
-
if (n > 0) {
|
|
36
|
-
setIsInitialVisiable(true);
|
|
37
|
-
}
|
|
38
|
-
};
|
|
39
|
-
|
|
40
|
-
const debounceRun = debounce(run, 150);
|
|
41
|
-
|
|
42
|
-
disposables.add(
|
|
43
|
-
instance.getMonacoModel().onDidChangeContent(() => {
|
|
44
|
-
debounceRun();
|
|
45
|
-
}),
|
|
46
|
-
);
|
|
47
|
-
|
|
48
|
-
run();
|
|
49
|
-
return () => {
|
|
50
|
-
disposables.dispose();
|
|
51
|
-
mergeConflictService.clear();
|
|
52
|
-
setIsInitialVisiable(false);
|
|
53
|
-
setConflictsCount(0);
|
|
54
|
-
};
|
|
55
|
-
}
|
|
56
|
-
}, [editorModel]);
|
|
57
|
-
|
|
58
|
-
return {
|
|
59
|
-
isVisiable: isInitialVisiable,
|
|
60
|
-
summary,
|
|
61
|
-
canNavigate: conflictsCount > 0,
|
|
62
|
-
};
|
|
63
|
-
}
|