@opensumi/ide-editor 3.1.4-next-1719380894.0 → 3.1.4
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/doc-model/editor-document-model.d.ts.map +1 -1
- package/lib/browser/doc-model/editor-document-model.js +1 -0
- package/lib/browser/doc-model/editor-document-model.js.map +1 -1
- package/lib/browser/doc-model/types.d.ts +1 -0
- package/lib/browser/doc-model/types.d.ts.map +1 -1
- package/lib/browser/doc-model/types.js.map +1 -1
- package/lib/browser/editor-collection.service.d.ts +0 -2
- package/lib/browser/editor-collection.service.d.ts.map +1 -1
- package/lib/browser/editor-collection.service.js +0 -4
- 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/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/doc-model/editor-document-model.ts +1 -0
- package/src/browser/doc-model/types.ts +1 -2
- package/src/browser/editor-collection.service.ts +0 -6
- 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/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
|
@@ -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,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,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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,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
|
-
}
|
|
@@ -1,65 +0,0 @@
|
|
|
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
|
-
}
|