@opensumi/ide-editor 3.1.2-next-1718766864.0 → 3.1.2-next-1718952012.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/merge-conflict/merge-conflict.model.d.ts +7 -0
- package/lib/browser/merge-conflict/merge-conflict.model.d.ts.map +1 -0
- package/lib/browser/merge-conflict/merge-conflict.model.js +51 -0
- package/lib/browser/merge-conflict/merge-conflict.model.js.map +1 -0
- package/lib/browser/merge-conflict/merge-conflict.service.d.ts +14 -0
- package/lib/browser/merge-conflict/merge-conflict.service.d.ts.map +1 -0
- package/lib/browser/merge-conflict/merge-conflict.service.js +66 -0
- package/lib/browser/merge-conflict/merge-conflict.service.js.map +1 -0
- package/lib/browser/merge-conflict/types.d.ts +0 -17
- package/lib/browser/merge-conflict/types.d.ts.map +1 -1
- package/lib/browser/merge-conflict/types.js +1 -6
- 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 +7 -40
- package/lib/browser/merge-editor/MergeEditorFloatComponents.js.map +1 -1
- package/package.json +14 -14
- package/src/browser/merge-conflict/merge-conflict.model.ts +63 -0
- package/src/browser/merge-conflict/merge-conflict.service.ts +65 -0
- package/src/browser/merge-conflict/types.ts +0 -21
- package/src/browser/merge-editor/MergeEditorFloatComponents.tsx +10 -45
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,51 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,14 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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"}
|
|
@@ -0,0 +1,66 @@
|
|
|
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
|
|
@@ -0,0 +1 @@
|
|
|
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,GAA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BAAoB,CAsDhC;AAtDY,oDAAoB"}
|
|
@@ -32,23 +32,6 @@ export interface IDocumentMergeConflictDescriptor {
|
|
|
32
32
|
export interface ICacheDocumentMergeConflict extends IDocumentMergeConflictDescriptor {
|
|
33
33
|
aiContent?: string;
|
|
34
34
|
}
|
|
35
|
-
export interface IDocumentMergeConflictTracker {
|
|
36
|
-
getConflicts(document: monaco.editor.ITextModel): PromiseLike<IDocumentMergeConflict[]>;
|
|
37
|
-
isPending(document: monaco.editor.ITextModel): boolean;
|
|
38
|
-
forget(document: monaco.editor.ITextModel): void;
|
|
39
|
-
}
|
|
40
|
-
export interface IDocumentMergeConflictTrackerService {
|
|
41
|
-
createTracker(origin: string): IDocumentMergeConflictTracker;
|
|
42
|
-
forget(document: monaco.editor.ITextModel): void;
|
|
43
|
-
}
|
|
44
|
-
export interface IDocumentMergeConflictNavigationResults {
|
|
45
|
-
canNavigate: boolean;
|
|
46
|
-
conflict?: IDocumentMergeConflict;
|
|
47
|
-
}
|
|
48
|
-
export declare enum NavigationDirection {
|
|
49
|
-
Forwards = 0,
|
|
50
|
-
Backwards = 1
|
|
51
|
-
}
|
|
52
35
|
export declare namespace AI_COMMAND {
|
|
53
36
|
const ACCEPT: string;
|
|
54
37
|
const REVERT: string;
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.d.ts","sourceRoot":"","sources":["../../../src/browser/merge-conflict/types.ts"],"names":[],"mappings":"AAAA,OAAO,KAAK,MAAM,MAAM,sBAAsB,CAAC;AAE/C,MAAM,WAAW,YAAY;IAC3B,IAAI,EAAE,MAAM,CAAC;IACb,MAAM,EAAE,MAAM,CAAC,KAAK,CAAC;IACrB,OAAO,EAAE,MAAM,CAAC,KAAK,CAAC;IACtB,gBAAgB,CAAC,EAAE,MAAM,CAAC,KAAK,CAAC;CACjC;AAED,0BAAkB,UAAU;IAC1B,OAAO,IAAA;IACP,QAAQ,IAAA;IACR,IAAI,IAAA;CACL;AAED,MAAM,WAAW,uBAA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R,IAAI,IAAA;CACL;AAED,MAAM,WAAW,uBAAuB;IACtC,cAAc,EAAE,OAAO,CAAC;IACxB,iBAAiB,EAAE,OAAO,CAAC;IAC3B,oBAAoB,EAAE,OAAO,CAAC;CAC/B;AAED,MAAM,WAAW,sBAAuB,SAAQ,gCAAgC;IAC9E,UAAU,CAAC,IAAI,EAAE,UAAU,EAAE,MAAM,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,GAAG,QAAQ,CAAC,OAAO,CAAC,CAAC;IAClF,SAAS,CACP,IAAI,EAAE,UAAU,EAChB,QAAQ,EAAE,MAAM,CAAC,MAAM,CAAC,UAAU,EAClC,IAAI,EAAE;QAAE,OAAO,CAAC,KAAK,EAAE,MAAM,CAAC,KAAK,EAAE,OAAO,EAAE,MAAM,GAAG,IAAI,CAAA;KAAE,GAC5D,IAAI,CAAC;CACT;AAED,MAAM,WAAW,gCAAgC;IAC/C,CAAC,CAAC,EAAE,MAAM,GAAG,GAAG,CAAC;IACjB,KAAK,EAAE,MAAM,CAAC,KAAK,CAAC;IACpB,OAAO,EAAE,YAAY,CAAC;IACtB,QAAQ,EAAE,YAAY,CAAC;IACvB,eAAe,EAAE,YAAY,EAAE,CAAC;IAChC,QAAQ,EAAE,MAAM,CAAC,KAAK,CAAC;CACxB;AAED,MAAM,WAAW,2BAA4B,SAAQ,gCAAgC;IACnF,SAAS,CAAC,EAAE,MAAM,CAAC;CACpB;AAED,yBAAiB,UAAU,CAAC;IAEnB,MAAM,MAAM,QAAgC,CAAC;IAC7C,MAAM,MAAM,QAAgC,CAAC;CACrD"}
|
|
@@ -1,11 +1,6 @@
|
|
|
1
1
|
"use strict";
|
|
2
2
|
Object.defineProperty(exports, "__esModule", { value: true });
|
|
3
|
-
exports.AI_COMMAND =
|
|
4
|
-
var NavigationDirection;
|
|
5
|
-
(function (NavigationDirection) {
|
|
6
|
-
NavigationDirection[NavigationDirection["Forwards"] = 0] = "Forwards";
|
|
7
|
-
NavigationDirection[NavigationDirection["Backwards"] = 1] = "Backwards";
|
|
8
|
-
})(NavigationDirection = exports.NavigationDirection || (exports.NavigationDirection = {}));
|
|
3
|
+
exports.AI_COMMAND = void 0;
|
|
9
4
|
var AI_COMMAND;
|
|
10
5
|
(function (AI_COMMAND) {
|
|
11
6
|
const MERGE_CONFLICT = 'merge-conflict';
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/browser/merge-conflict/types.ts"],"names":[],"mappings":";;;
|
|
1
|
+
{"version":3,"file":"types.js","sourceRoot":"","sources":["../../../src/browser/merge-conflict/types.ts"],"names":[],"mappings":";;;AA2CA,IAAiB,UAAU,CAI1B;AAJD,WAAiB,UAAU;IACzB,MAAM,cAAc,GAAG,gBAAgB,CAAC;IAC3B,iBAAM,GAAG,GAAG,cAAc,YAAY,CAAC;IACvC,iBAAM,GAAG,GAAG,cAAc,YAAY,CAAC;AACtD,CAAC,EAJgB,UAAU,GAAV,kBAAU,KAAV,kBAAU,QAI1B"}
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MergeEditorFloatComponents.d.ts","sourceRoot":"","sources":["../../../src/browser/merge-editor/MergeEditorFloatComponents.tsx"],"names":[],"mappings":"AAEA,OAAO,
|
|
1
|
+
{"version":3,"file":"MergeEditorFloatComponents.d.ts","sourceRoot":"","sources":["../../../src/browser/merge-editor/MergeEditorFloatComponents.tsx"],"names":[],"mappings":"AAEA,OAAO,EAKL,GAAG,EAEJ,MAAM,4BAA4B,CAAC;AAKpC,OAAO,EAAE,oBAAoB,EAAE,MAAM,UAAU,CAAC;AAEhD,eAAO,MAAM,0BAA0B,EAAE,oBAAoB,CAAC;IAAE,GAAG,EAAE,GAAG,CAAA;CAAE,CAsDzE,CAAC"}
|
|
@@ -4,53 +4,21 @@ exports.MergeEditorFloatComponents = void 0;
|
|
|
4
4
|
const tslib_1 = require("tslib");
|
|
5
5
|
const react_1 = tslib_1.__importStar(require("react"));
|
|
6
6
|
const ide_core_browser_1 = require("@opensumi/ide-core-browser");
|
|
7
|
-
const ide_core_common_1 = require("@opensumi/ide-core-common");
|
|
8
|
-
const git_1 = require("@opensumi/ide-core-common/lib/commands/git");
|
|
9
7
|
const merge_actions_1 = require("@opensumi/ide-monaco/lib/browser/contrib/merge-editor/components/merge-actions");
|
|
10
|
-
const
|
|
11
|
-
const
|
|
8
|
+
const merge_conflict_model_1 = require("../merge-conflict/merge-conflict.model");
|
|
9
|
+
const merge_conflict_service_1 = require("../merge-conflict/merge-conflict.service");
|
|
12
10
|
const MergeEditorFloatComponents = ({ resource }) => {
|
|
13
11
|
const { uri } = resource;
|
|
14
|
-
const
|
|
15
|
-
const mergeConflictParser = (0, ide_core_browser_1.useInjectable)(merge_conflict_1.MergeConflictParser);
|
|
12
|
+
const mergeConflictService = (0, ide_core_browser_1.useInjectable)(merge_conflict_service_1.MergeConflictService);
|
|
16
13
|
const commandService = (0, ide_core_browser_1.useInjectable)(ide_core_browser_1.CommandService);
|
|
17
14
|
const commandRegistry = (0, ide_core_browser_1.useInjectable)(ide_core_browser_1.CommandRegistry);
|
|
18
|
-
const
|
|
19
|
-
const [conflicts, setConflicts] = (0, react_1.useState)([]);
|
|
20
|
-
(0, react_1.useEffect)(() => {
|
|
21
|
-
const disposables = new ide_core_browser_1.DisposableStore();
|
|
22
|
-
if (editorModel) {
|
|
23
|
-
const { instance } = editorModel;
|
|
24
|
-
const run = () => {
|
|
25
|
-
const conflicts = mergeConflictParser.scanDocument(instance.getMonacoModel());
|
|
26
|
-
if (conflicts.length > 0) {
|
|
27
|
-
setIsVisiable(true);
|
|
28
|
-
setConflicts(conflicts);
|
|
29
|
-
}
|
|
30
|
-
else {
|
|
31
|
-
setIsVisiable(false);
|
|
32
|
-
setConflicts([]);
|
|
33
|
-
}
|
|
34
|
-
};
|
|
35
|
-
disposables.add(editorModel.instance.getMonacoModel().onDidChangeContent(() => {
|
|
36
|
-
run();
|
|
37
|
-
}));
|
|
38
|
-
run();
|
|
39
|
-
return () => {
|
|
40
|
-
disposables.dispose();
|
|
41
|
-
};
|
|
42
|
-
}
|
|
43
|
-
}, [editorModel]);
|
|
15
|
+
const { canNavigate, isVisiable, summary } = (0, merge_conflict_model_1.useMergeConflictModel)(uri);
|
|
44
16
|
const [isAIResolving, setIsAIResolving] = (0, react_1.useState)(false);
|
|
45
17
|
const handlePrev = (0, react_1.useCallback)(() => {
|
|
46
|
-
|
|
47
|
-
// TODO: 编辑器向上滚动一行
|
|
48
|
-
});
|
|
18
|
+
mergeConflictService.navigatePrevious();
|
|
49
19
|
}, []);
|
|
50
20
|
const handleNext = (0, react_1.useCallback)(() => {
|
|
51
|
-
|
|
52
|
-
// TODO: 编辑器向上滚动一行
|
|
53
|
-
});
|
|
21
|
+
mergeConflictService.navigateNext();
|
|
54
22
|
}, []);
|
|
55
23
|
const handleAIResolve = (0, react_1.useCallback)(async () => {
|
|
56
24
|
setIsAIResolving(true);
|
|
@@ -65,8 +33,7 @@ const MergeEditorFloatComponents = ({ resource }) => {
|
|
|
65
33
|
if (!isVisiable) {
|
|
66
34
|
return null;
|
|
67
35
|
}
|
|
68
|
-
|
|
69
|
-
return (react_1.default.createElement(merge_actions_1.MergeActions, { uri: uri, editorType: 'text', summary: summary, handleNext: handleNext, handlePrev: handlePrev, isAIResolving: isAIResolving, onAIResolve: handleAIResolve, onReset: () => {
|
|
36
|
+
return (react_1.default.createElement(merge_actions_1.MergeActions, { uri: uri, editorType: 'text', summary: summary, canNavigate: canNavigate, handleNext: handleNext, handlePrev: handlePrev, isAIResolving: isAIResolving, onAIResolve: handleAIResolve, onReset: () => {
|
|
70
37
|
commandService.executeCommand(ide_core_browser_1.MERGE_CONFLICT_COMMANDS.ALL_RESET.id, uri);
|
|
71
38
|
}, onSwitchEditor: () => {
|
|
72
39
|
[ide_core_browser_1.SCM_COMMANDS.GIT_OPEN_MERGE_EDITOR, ide_core_browser_1.SCM_COMMANDS._GIT_OPEN_MERGE_EDITOR].forEach(({ id: command }) => {
|
|
@@ -1 +1 @@
|
|
|
1
|
-
{"version":3,"file":"MergeEditorFloatComponents.js","sourceRoot":"","sources":["../../../src/browser/merge-editor/MergeEditorFloatComponents.tsx"],"names":[],"mappings":";;;;AAAA,
|
|
1
|
+
{"version":3,"file":"MergeEditorFloatComponents.js","sourceRoot":"","sources":["../../../src/browser/merge-editor/MergeEditorFloatComponents.tsx"],"names":[],"mappings":";;;;AAAA,uDAAqD;AAErD,iEAOoC;AACpC,kHAA8G;AAE9G,iFAA+E;AAC/E,qFAAgF;AAGzE,MAAM,0BAA0B,GAAuC,CAAC,EAAE,QAAQ,EAAE,EAAE,EAAE;IAC7F,MAAM,EAAE,GAAG,EAAE,GAAG,QAAQ,CAAC;IACzB,MAAM,oBAAoB,GAAG,IAAA,gCAAa,EAAuB,6CAAoB,CAAC,CAAC;IACvF,MAAM,cAAc,GAAG,IAAA,gCAAa,EAAiB,iCAAc,CAAC,CAAC;IACrE,MAAM,eAAe,GAAG,IAAA,gCAAa,EAAkB,kCAAe,CAAC,CAAC;IAExE,MAAM,EAAE,WAAW,EAAE,UAAU,EAAE,OAAO,EAAE,GAAG,IAAA,4CAAqB,EAAC,GAAG,CAAC,CAAC;IAExE,MAAM,CAAC,aAAa,EAAE,gBAAgB,CAAC,GAAG,IAAA,gBAAQ,EAAC,KAAK,CAAC,CAAC;IAE1D,MAAM,UAAU,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAClC,oBAAoB,CAAC,gBAAgB,EAAE,CAAC;IAC1C,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,UAAU,GAAG,IAAA,mBAAW,EAAC,GAAG,EAAE;QAClC,oBAAoB,CAAC,YAAY,EAAE,CAAC;IACtC,CAAC,EAAE,EAAE,CAAC,CAAC;IAEP,MAAM,eAAe,GAAG,IAAA,mBAAW,EAAC,KAAK,IAAI,EAAE;QAC7C,gBAAgB,CAAC,IAAI,CAAC,CAAC;QACvB,IAAI,aAAa,EAAE;YACjB,MAAM,cAA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version": "3.1.2-next-
|
|
3
|
+
"version": "3.1.2-next-1718952012.0",
|
|
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-next-
|
|
21
|
-
"@opensumi/ide-core-node": "3.1.2-next-
|
|
22
|
-
"@opensumi/ide-file-service": "3.1.2-next-
|
|
23
|
-
"@opensumi/ide-monaco": "3.1.2-next-
|
|
24
|
-
"@opensumi/ide-utils": "3.1.2-next-
|
|
20
|
+
"@opensumi/ide-core-common": "3.1.2-next-1718952012.0",
|
|
21
|
+
"@opensumi/ide-core-node": "3.1.2-next-1718952012.0",
|
|
22
|
+
"@opensumi/ide-file-service": "3.1.2-next-1718952012.0",
|
|
23
|
+
"@opensumi/ide-monaco": "3.1.2-next-1718952012.0",
|
|
24
|
+
"@opensumi/ide-utils": "3.1.2-next-1718952012.0",
|
|
25
25
|
"vscode-oniguruma": "1.5.1"
|
|
26
26
|
},
|
|
27
27
|
"devDependencies": {
|
|
28
|
-
"@opensumi/ide-components": "3.1.2-next-
|
|
29
|
-
"@opensumi/ide-core-browser": "3.1.2-next-
|
|
30
|
-
"@opensumi/ide-dev-tool": "3.1.2-next-
|
|
31
|
-
"@opensumi/ide-overlay": "3.1.2-next-
|
|
32
|
-
"@opensumi/ide-quick-open": "3.1.2-next-
|
|
33
|
-
"@opensumi/ide-theme": "3.1.2-next-
|
|
34
|
-
"@opensumi/ide-workspace": "3.1.2-next-
|
|
28
|
+
"@opensumi/ide-components": "3.1.2-next-1718952012.0",
|
|
29
|
+
"@opensumi/ide-core-browser": "3.1.2-next-1718952012.0",
|
|
30
|
+
"@opensumi/ide-dev-tool": "3.1.2-next-1718952012.0",
|
|
31
|
+
"@opensumi/ide-overlay": "3.1.2-next-1718952012.0",
|
|
32
|
+
"@opensumi/ide-quick-open": "3.1.2-next-1718952012.0",
|
|
33
|
+
"@opensumi/ide-theme": "3.1.2-next-1718952012.0",
|
|
34
|
+
"@opensumi/ide-workspace": "3.1.2-next-1718952012.0"
|
|
35
35
|
},
|
|
36
|
-
"gitHead": "
|
|
36
|
+
"gitHead": "ee27e5b0988eff0cb1c426f473ecae4b7603e7d7"
|
|
37
37
|
}
|
|
@@ -0,0 +1,63 @@
|
|
|
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
|
+
}
|
|
@@ -0,0 +1,65 @@
|
|
|
1
|
+
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
|
+
import * as monaco from '@opensumi/ide-monaco';
|
|
3
|
+
import { NavigationDirection, findRangeForNavigation } from '@opensumi/ide-monaco/lib/browser/contrib/merge-editor';
|
|
4
|
+
import { IMessageService } from '@opensumi/ide-overlay';
|
|
5
|
+
|
|
6
|
+
import { IEditor, WorkbenchEditorService } from '../types';
|
|
7
|
+
|
|
8
|
+
import { DocumentMergeConflict, MergeConflictParser } from './conflict-parser';
|
|
9
|
+
|
|
10
|
+
@Injectable()
|
|
11
|
+
export class MergeConflictService {
|
|
12
|
+
@Autowired(MergeConflictParser)
|
|
13
|
+
parser: MergeConflictParser;
|
|
14
|
+
|
|
15
|
+
@Autowired(WorkbenchEditorService)
|
|
16
|
+
private readonly editorService: WorkbenchEditorService;
|
|
17
|
+
|
|
18
|
+
@Autowired(IMessageService)
|
|
19
|
+
private readonly messageService: IMessageService;
|
|
20
|
+
|
|
21
|
+
conflicts = [] as DocumentMergeConflict[];
|
|
22
|
+
|
|
23
|
+
scanDocument(model: monaco.editor.ITextModel) {
|
|
24
|
+
this.conflicts = this.parser.scanDocument(model);
|
|
25
|
+
return this.conflicts.length;
|
|
26
|
+
}
|
|
27
|
+
|
|
28
|
+
clear(): void {
|
|
29
|
+
this.conflicts = [];
|
|
30
|
+
}
|
|
31
|
+
|
|
32
|
+
private async navigate(editor: IEditor, direction: NavigationDirection): Promise<void> {
|
|
33
|
+
this.conflicts = this.parser.scanDocument(editor.monacoEditor.getModel()!);
|
|
34
|
+
const ranges = this.conflicts.map((conflict) => conflict.range);
|
|
35
|
+
|
|
36
|
+
const navigationResult = findRangeForNavigation(direction, ranges, editor.monacoEditor.getPosition()!);
|
|
37
|
+
|
|
38
|
+
if (!navigationResult) {
|
|
39
|
+
this.messageService.warning('No merge conflicts found in this file');
|
|
40
|
+
return;
|
|
41
|
+
} else if (!navigationResult.canNavigate) {
|
|
42
|
+
this.messageService.warning('No other merge conflicts within this file');
|
|
43
|
+
return;
|
|
44
|
+
} else if (!navigationResult.range) {
|
|
45
|
+
// impossible path
|
|
46
|
+
return;
|
|
47
|
+
}
|
|
48
|
+
|
|
49
|
+
editor.monacoEditor.setPosition(navigationResult.range.getStartPosition());
|
|
50
|
+
|
|
51
|
+
// when navigating, we want to show the codelens on the first line of the conflict
|
|
52
|
+
const range = navigationResult.range.delta(-1);
|
|
53
|
+
|
|
54
|
+
editor.monacoEditor.revealRangeNearTopIfOutsideViewport(range);
|
|
55
|
+
editor.monacoEditor.focus();
|
|
56
|
+
}
|
|
57
|
+
|
|
58
|
+
navigateNext(): Promise<void> {
|
|
59
|
+
return this.navigate(this.editorService.currentEditor!, NavigationDirection.Forwards);
|
|
60
|
+
}
|
|
61
|
+
|
|
62
|
+
navigatePrevious(): Promise<void> {
|
|
63
|
+
return this.navigate(this.editorService.currentEditor!, NavigationDirection.Backwards);
|
|
64
|
+
}
|
|
65
|
+
}
|
|
@@ -41,27 +41,6 @@ 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
|
-
|
|
65
44
|
export namespace AI_COMMAND {
|
|
66
45
|
const MERGE_CONFLICT = 'merge-conflict';
|
|
67
46
|
export const ACCEPT = `${MERGE_CONFLICT}.ai.accept`;
|
|
@@ -1,72 +1,37 @@
|
|
|
1
|
-
import React, { useCallback,
|
|
1
|
+
import React, { useCallback, useState } from 'react';
|
|
2
2
|
|
|
3
3
|
import {
|
|
4
4
|
CommandRegistry,
|
|
5
5
|
CommandService,
|
|
6
|
-
DisposableStore,
|
|
7
6
|
MERGE_CONFLICT_COMMANDS,
|
|
8
7
|
SCM_COMMANDS,
|
|
9
8
|
URI,
|
|
10
9
|
useInjectable,
|
|
11
10
|
} from '@opensumi/ide-core-browser';
|
|
12
|
-
import { formatLocalize } from '@opensumi/ide-core-common';
|
|
13
|
-
import { MergeConflictCommands } from '@opensumi/ide-core-common/lib/commands/git';
|
|
14
11
|
import { MergeActions } from '@opensumi/ide-monaco/lib/browser/contrib/merge-editor/components/merge-actions';
|
|
15
12
|
|
|
16
|
-
import {
|
|
17
|
-
import {
|
|
13
|
+
import { useMergeConflictModel } from '../merge-conflict/merge-conflict.model';
|
|
14
|
+
import { MergeConflictService } from '../merge-conflict/merge-conflict.service';
|
|
18
15
|
import { ReactEditorComponent } from '../types';
|
|
19
16
|
|
|
20
17
|
export const MergeEditorFloatComponents: ReactEditorComponent<{ uri: URI }> = ({ resource }) => {
|
|
21
18
|
const { uri } = resource;
|
|
22
|
-
const
|
|
23
|
-
const mergeConflictParser: MergeConflictParser = useInjectable(MergeConflictParser);
|
|
19
|
+
const mergeConflictService = useInjectable<MergeConflictService>(MergeConflictService);
|
|
24
20
|
const commandService = useInjectable<CommandService>(CommandService);
|
|
25
21
|
const commandRegistry = useInjectable<CommandRegistry>(CommandRegistry);
|
|
26
22
|
|
|
27
|
-
const
|
|
28
|
-
const [conflicts, setConflicts] = useState<DocumentMergeConflict[]>([]);
|
|
29
|
-
|
|
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]);
|
|
23
|
+
const { canNavigate, isVisiable, summary } = useMergeConflictModel(uri);
|
|
57
24
|
|
|
58
25
|
const [isAIResolving, setIsAIResolving] = useState(false);
|
|
26
|
+
|
|
59
27
|
const handlePrev = useCallback(() => {
|
|
60
|
-
|
|
61
|
-
// TODO: 编辑器向上滚动一行
|
|
62
|
-
});
|
|
28
|
+
mergeConflictService.navigatePrevious();
|
|
63
29
|
}, []);
|
|
64
30
|
|
|
65
31
|
const handleNext = useCallback(() => {
|
|
66
|
-
|
|
67
|
-
// TODO: 编辑器向上滚动一行
|
|
68
|
-
});
|
|
32
|
+
mergeConflictService.navigateNext();
|
|
69
33
|
}, []);
|
|
34
|
+
|
|
70
35
|
const handleAIResolve = useCallback(async () => {
|
|
71
36
|
setIsAIResolving(true);
|
|
72
37
|
if (isAIResolving) {
|
|
@@ -81,12 +46,12 @@ export const MergeEditorFloatComponents: ReactEditorComponent<{ uri: URI }> = ({
|
|
|
81
46
|
return null;
|
|
82
47
|
}
|
|
83
48
|
|
|
84
|
-
const summary = formatLocalize('merge-conflicts.merge.conflict.remain', conflicts.length);
|
|
85
49
|
return (
|
|
86
50
|
<MergeActions
|
|
87
51
|
uri={uri}
|
|
88
52
|
editorType='text'
|
|
89
53
|
summary={summary}
|
|
54
|
+
canNavigate={canNavigate}
|
|
90
55
|
handleNext={handleNext}
|
|
91
56
|
handlePrev={handlePrev}
|
|
92
57
|
isAIResolving={isAIResolving}
|