@opensumi/ide-editor 2.27.3-next-1711507853.0 → 2.27.3-next-1711612363.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/decoration-applier.d.ts +1 -1
- package/lib/browser/decoration-applier.d.ts.map +1 -1
- package/lib/browser/decoration-applier.js +0 -1
- package/lib/browser/decoration-applier.js.map +1 -1
- package/lib/browser/diff/compare.d.ts +2 -1
- package/lib/browser/diff/compare.d.ts.map +1 -1
- package/lib/browser/diff/compare.js +26 -4
- 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/doc-model/override.d.ts +1 -1
- package/lib/browser/doc-model/override.d.ts.map +1 -1
- package/lib/browser/doc-model/saveParticipants.d.ts.map +1 -1
- package/lib/browser/doc-model/saveParticipants.js +2 -2
- package/lib/browser/doc-model/saveParticipants.js.map +1 -1
- package/lib/browser/doc-model/types.d.ts +1 -1
- package/lib/browser/doc-model/types.d.ts.map +1 -1
- package/lib/browser/editor-collection.service.d.ts +6 -5
- package/lib/browser/editor-collection.service.d.ts.map +1 -1
- package/lib/browser/editor-collection.service.js +10 -4
- package/lib/browser/editor-collection.service.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 +35 -1
- package/lib/browser/editor.contribution.js.map +1 -1
- package/lib/browser/editor.decoration.service.d.ts +1 -1
- package/lib/browser/editor.decoration.service.d.ts.map +1 -1
- package/lib/browser/editor.decoration.service.js.map +1 -1
- package/lib/browser/editor.module.less +49 -3
- package/lib/browser/editor.override.d.ts +2 -2
- package/lib/browser/editor.override.d.ts.map +1 -1
- package/lib/browser/editor.override.js +8 -11
- package/lib/browser/editor.override.js.map +1 -1
- package/lib/browser/feature.d.ts +1 -1
- package/lib/browser/format/formatterSelect.d.ts +1 -1
- package/lib/browser/format/formatterSelect.d.ts.map +1 -1
- package/lib/browser/format/formatterSelect.js.map +1 -1
- package/lib/browser/language/diagnostic-collection.d.ts +4 -3
- package/lib/browser/language/diagnostic-collection.d.ts.map +1 -1
- package/lib/browser/language/diagnostic-collection.js +5 -6
- package/lib/browser/language/diagnostic-collection.js.map +1 -1
- package/lib/browser/language/language.service.d.ts +1 -1
- package/lib/browser/language/language.service.d.ts.map +1 -1
- package/lib/browser/language/language.service.js.map +1 -1
- package/lib/browser/menu/editor.context.d.ts.map +1 -1
- package/lib/browser/menu/editor.context.js +1 -1
- package/lib/browser/menu/editor.context.js.map +1 -1
- 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/monaco-contrib/callHierarchy/callHierarchy.service.d.ts +1 -3
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.d.ts.map +1 -1
- package/lib/browser/monaco-contrib/callHierarchy/callHierarchy.service.js.map +1 -1
- package/lib/browser/monaco-contrib/command/command.service.d.ts +1 -1
- package/lib/browser/monaco-contrib/command/command.service.d.ts.map +1 -1
- package/lib/browser/monaco-contrib/command/command.service.js +1 -1
- package/lib/browser/monaco-contrib/command/command.service.js.map +1 -1
- package/lib/browser/monaco-contrib/tokenizer/textmate-tokenizer.d.ts +1 -1
- package/lib/browser/monaco-contrib/tokenizer/textmate-tokenizer.d.ts.map +1 -1
- package/lib/browser/monaco-contrib/tokenizer/textmate-tokenizer.js.map +1 -1
- package/lib/browser/preference/converter.d.ts.map +1 -1
- package/lib/browser/preference/converter.js +70 -2
- package/lib/browser/preference/converter.js.map +1 -1
- package/lib/browser/preference/schema.d.ts +18 -0
- package/lib/browser/preference/schema.d.ts.map +1 -1
- package/lib/browser/preference/schema.js +86 -19
- package/lib/browser/preference/schema.js.map +1 -1
- package/lib/browser/quick-open/go-to-line.d.ts +1 -1
- package/lib/browser/quick-open/go-to-line.d.ts.map +1 -1
- package/lib/browser/quick-open/go-to-line.js +1 -1
- package/lib/browser/quick-open/go-to-line.js.map +1 -1
- package/lib/browser/types.d.ts +1 -1
- package/lib/browser/types.d.ts.map +1 -1
- package/lib/browser/workbench-editor.service.d.ts.map +1 -1
- package/lib/browser/workbench-editor.service.js +4 -1
- package/lib/browser/workbench-editor.service.js.map +1 -1
- package/lib/common/language.d.ts +1 -1
- package/lib/common/language.d.ts.map +1 -1
- package/lib/common/language.js.map +1 -1
- package/package.json +14 -14
- package/src/browser/decoration-applier.ts +1 -2
- package/src/browser/diff/compare.ts +38 -21
- package/src/browser/doc-model/editor-document-model.ts +2 -1
- package/src/browser/doc-model/override.ts +1 -1
- package/src/browser/doc-model/saveParticipants.ts +3 -5
- package/src/browser/doc-model/types.ts +1 -1
- package/src/browser/editor-collection.service.ts +10 -6
- package/src/browser/editor.contribution.ts +37 -1
- package/src/browser/editor.decoration.service.ts +1 -1
- package/src/browser/editor.module.less +49 -3
- package/src/browser/editor.override.ts +10 -13
- package/src/browser/format/formatterSelect.ts +3 -3
- package/src/browser/language/diagnostic-collection.ts +8 -10
- package/src/browser/language/language.service.ts +1 -1
- package/src/browser/menu/editor.context.ts +1 -1
- package/src/browser/merge-editor/MergeEditorFloatComponents.tsx +101 -4
- package/src/browser/merge-editor/merge-editor.contribution.ts +4 -8
- package/src/browser/monaco-contrib/callHierarchy/callHierarchy.service.ts +1 -2
- package/src/browser/monaco-contrib/command/command.service.ts +2 -2
- package/src/browser/monaco-contrib/tokenizer/textmate-tokenizer.ts +1 -1
- package/src/browser/preference/converter.ts +76 -4
- package/src/browser/preference/schema.ts +93 -18
- package/src/browser/quick-open/go-to-line.ts +1 -1
- package/src/browser/types.ts +1 -1
- package/src/browser/view/topPadding.ts +1 -1
- package/src/browser/workbench-editor.service.ts +3 -1
- package/src/common/language.ts +1 -1
|
@@ -4,6 +4,7 @@ import { Autowired, Injectable } from '@opensumi/di';
|
|
|
4
4
|
import {
|
|
5
5
|
CommandService,
|
|
6
6
|
Disposable,
|
|
7
|
+
EDITOR_COMMANDS,
|
|
7
8
|
Emitter,
|
|
8
9
|
IEventBus,
|
|
9
10
|
ILogger,
|
|
@@ -686,7 +687,7 @@ export class EditorDocumentModel extends Disposable implements IEditorDocumentMo
|
|
|
686
687
|
reject(err);
|
|
687
688
|
}, formatOnSaveTimeout);
|
|
688
689
|
}),
|
|
689
|
-
this.commandService.executeCommand(
|
|
690
|
+
this.commandService.executeCommand(EDITOR_COMMANDS.FORMAT_DOCUMENT.id),
|
|
690
691
|
]);
|
|
691
692
|
} catch (err) {
|
|
692
693
|
if (err.name === 'FormatOnSaveTimeoutError') {
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
/* istanbul ignore file */
|
|
2
2
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
3
3
|
import { URI } from '@opensumi/ide-core-browser';
|
|
4
|
+
import * as monaco from '@opensumi/ide-monaco';
|
|
4
5
|
import {
|
|
5
6
|
ITextModelContentProvider,
|
|
6
7
|
ITextModelService,
|
|
7
8
|
} from '@opensumi/monaco-editor-core/esm/vs/editor/common/services/resolverService';
|
|
8
|
-
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
|
|
9
9
|
|
|
10
10
|
import { IEditorDocumentModelService } from './types';
|
|
11
11
|
|
|
@@ -15,6 +15,7 @@ import {
|
|
|
15
15
|
formatLocalize,
|
|
16
16
|
} from '@opensumi/ide-core-browser';
|
|
17
17
|
import { IProgressService } from '@opensumi/ide-core-browser/lib/progress';
|
|
18
|
+
import * as monaco from '@opensumi/ide-monaco';
|
|
18
19
|
import { ResourceEdit } from '@opensumi/ide-monaco/lib/browser/monaco-api';
|
|
19
20
|
import { languageFeaturesService } from '@opensumi/ide-monaco/lib/browser/monaco-api/languages';
|
|
20
21
|
import { ITextModel } from '@opensumi/ide-monaco/lib/browser/monaco-api/types';
|
|
@@ -25,15 +26,12 @@ import { EditOperation } from '@opensumi/monaco-editor-core/esm/vs/editor/common
|
|
|
25
26
|
import { Range } from '@opensumi/monaco-editor-core/esm/vs/editor/common/core/range';
|
|
26
27
|
import * as languages from '@opensumi/monaco-editor-core/esm/vs/editor/common/languages';
|
|
27
28
|
import { CodeActionProvider } from '@opensumi/monaco-editor-core/esm/vs/editor/common/languages';
|
|
29
|
+
import { getCodeActions } from '@opensumi/monaco-editor-core/esm/vs/editor/contrib/codeAction/browser/codeAction';
|
|
28
30
|
import {
|
|
29
31
|
CodeActionItem,
|
|
30
|
-
getCodeActions,
|
|
31
|
-
} from '@opensumi/monaco-editor-core/esm/vs/editor/contrib/codeAction/browser/codeAction';
|
|
32
|
-
import {
|
|
33
32
|
CodeActionKind,
|
|
34
33
|
CodeActionTriggerSource,
|
|
35
|
-
} from '@opensumi/monaco-editor-core/esm/vs/editor/contrib/codeAction/
|
|
36
|
-
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
|
|
34
|
+
} from '@opensumi/monaco-editor-core/esm/vs/editor/contrib/codeAction/common/types';
|
|
37
35
|
|
|
38
36
|
import { MonacoCodeService } from '../editor.override';
|
|
39
37
|
import { SaveReason } from '../types';
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
MaybePromise,
|
|
9
9
|
URI,
|
|
10
10
|
} from '@opensumi/ide-core-browser';
|
|
11
|
+
import * as monaco from '@opensumi/ide-monaco';
|
|
11
12
|
import { EOL, EndOfLineSequence } from '@opensumi/ide-monaco/lib/browser/monaco-api/types';
|
|
12
|
-
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
|
|
13
13
|
|
|
14
14
|
import { IEditorDocumentModelContentChange, SaveReason } from '../../common';
|
|
15
15
|
import { IEditorDocumentModel, IEditorDocumentModelRef } from '../../common/editor';
|
|
@@ -1,5 +1,5 @@
|
|
|
1
1
|
import { Autowired, INJECTOR_TOKEN, Injectable, Injector } from '@opensumi/di';
|
|
2
|
-
import { IContextKeyService, IRange } from '@opensumi/ide-core-browser';
|
|
2
|
+
import { IContextKeyService, IRange, PreferenceService } from '@opensumi/ide-core-browser';
|
|
3
3
|
import { ResourceContextKey } from '@opensumi/ide-core-browser/lib/contextkey';
|
|
4
4
|
import { MonacoService } from '@opensumi/ide-core-browser/lib/monaco';
|
|
5
5
|
import {
|
|
@@ -14,7 +14,7 @@ import {
|
|
|
14
14
|
isEmptyObject,
|
|
15
15
|
objects,
|
|
16
16
|
} from '@opensumi/ide-core-common';
|
|
17
|
-
import * as monaco from '@opensumi/monaco
|
|
17
|
+
import * as monaco from '@opensumi/ide-monaco';
|
|
18
18
|
import { IConfigurationService } from '@opensumi/monaco-editor-core/esm/vs/platform/configuration/common/configuration';
|
|
19
19
|
|
|
20
20
|
import {
|
|
@@ -283,7 +283,7 @@ export abstract class BaseMonacoEditorWrapper extends WithEventBus implements IE
|
|
|
283
283
|
);
|
|
284
284
|
this.addDispose(
|
|
285
285
|
this.configurationService.onDidChangeConfiguration((e) => {
|
|
286
|
-
const changedEditorKeys = e.affectedKeys.filter((key) => isEditorOption(key));
|
|
286
|
+
const changedEditorKeys = Array.from(e.affectedKeys.values()).filter((key) => isEditorOption(key));
|
|
287
287
|
if (changedEditorKeys.length > 0) {
|
|
288
288
|
this._doUpdateOptions();
|
|
289
289
|
}
|
|
@@ -585,6 +585,9 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
585
585
|
@Autowired(IConfigurationService)
|
|
586
586
|
protected readonly configurationService: IConfigurationService;
|
|
587
587
|
|
|
588
|
+
@Autowired(PreferenceService)
|
|
589
|
+
protected readonly preferenceService: PreferenceService;
|
|
590
|
+
|
|
588
591
|
@Autowired(IContextKeyService)
|
|
589
592
|
protected readonly contextKeyService: IContextKeyService;
|
|
590
593
|
|
|
@@ -617,7 +620,7 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
617
620
|
this.wrapEditors();
|
|
618
621
|
this.addDispose(
|
|
619
622
|
this.configurationService.onDidChangeConfiguration((e) => {
|
|
620
|
-
const changedEditorKeys = e.affectedKeys.filter((key) => isDiffEditorOption(key));
|
|
623
|
+
const changedEditorKeys = Array.from(e.affectedKeys.values()).filter((key) => isDiffEditorOption(key));
|
|
621
624
|
if (changedEditorKeys.length > 0) {
|
|
622
625
|
this.doUpdateDiffOptions();
|
|
623
626
|
}
|
|
@@ -678,8 +681,9 @@ export class BrowserDiffEditor extends WithEventBus implements IDiffEditor {
|
|
|
678
681
|
} else {
|
|
679
682
|
this.restoreState();
|
|
680
683
|
}
|
|
681
|
-
|
|
682
|
-
if (options.revealFirstDiff) {
|
|
684
|
+
const enableHideUnchanged = this.preferenceService.get('diffEditor.hideUnchangedRegions.enabled');
|
|
685
|
+
if (options.revealFirstDiff && !enableHideUnchanged) {
|
|
686
|
+
// 仅在非折叠模式下自动滚动到第一个 Diff
|
|
683
687
|
const diffs = this.monacoDiffEditor.getLineChanges();
|
|
684
688
|
if (diffs && diffs.length > 0) {
|
|
685
689
|
this.showFirstDiff();
|
|
@@ -16,6 +16,7 @@ import {
|
|
|
16
16
|
IEventBus,
|
|
17
17
|
IOpenerService,
|
|
18
18
|
IPreferenceSettingsService,
|
|
19
|
+
IQuickInputService,
|
|
19
20
|
IQuickOpenHandlerRegistry,
|
|
20
21
|
KeybindingContribution,
|
|
21
22
|
KeybindingRegistry,
|
|
@@ -45,8 +46,8 @@ import { ILogger, PreferenceScope, isWindows } from '@opensumi/ide-core-common';
|
|
|
45
46
|
import { MergeEditorService } from '@opensumi/ide-monaco/lib/browser/contrib/merge-editor/merge-editor.service';
|
|
46
47
|
import { ITextmateTokenizer, ITextmateTokenizerService } from '@opensumi/ide-monaco/lib/browser/contrib/tokenizer';
|
|
47
48
|
import { EOL } from '@opensumi/ide-monaco/lib/browser/monaco-api/types';
|
|
49
|
+
import * as monaco from '@opensumi/ide-monaco/lib/common/common';
|
|
48
50
|
import { EditorContextKeys } from '@opensumi/monaco-editor-core/esm/vs/editor/common/editorContextKeys';
|
|
49
|
-
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
|
|
50
51
|
import { ContextKeyExpr } from '@opensumi/monaco-editor-core/esm/vs/platform/contextkey/common/contextkey';
|
|
51
52
|
import { SyncDescriptor } from '@opensumi/monaco-editor-core/esm/vs/platform/instantiation/common/descriptors';
|
|
52
53
|
|
|
@@ -172,6 +173,12 @@ export class EditorContribution
|
|
|
172
173
|
@Autowired(IEditorDocumentModelContentRegistry)
|
|
173
174
|
contentRegistry: IEditorDocumentModelContentRegistry;
|
|
174
175
|
|
|
176
|
+
@Autowired(IQuickInputService)
|
|
177
|
+
private readonly quickInputService: IQuickInputService;
|
|
178
|
+
|
|
179
|
+
@Autowired(CommandService)
|
|
180
|
+
private readonly commandService: CommandService;
|
|
181
|
+
|
|
175
182
|
registerComponent(registry: ComponentRegistry) {
|
|
176
183
|
registry.register('@opensumi/ide-editor', {
|
|
177
184
|
id: 'ide-editor',
|
|
@@ -502,6 +509,35 @@ export class EditorContribution
|
|
|
502
509
|
},
|
|
503
510
|
});
|
|
504
511
|
|
|
512
|
+
commands.registerCommand(EDITOR_COMMANDS.OPEN_MERGEEDITOR_DEV, {
|
|
513
|
+
execute: async () => {
|
|
514
|
+
try {
|
|
515
|
+
const value = await this.quickInputService.open({ value: '' });
|
|
516
|
+
if (!value) {
|
|
517
|
+
return;
|
|
518
|
+
}
|
|
519
|
+
|
|
520
|
+
const toArgs = JSON.parse(value);
|
|
521
|
+
|
|
522
|
+
/**
|
|
523
|
+
* @example
|
|
524
|
+
* {
|
|
525
|
+
* input1: {
|
|
526
|
+
* uri: 'current 分支的 uri'
|
|
527
|
+
* },
|
|
528
|
+
* input2: {
|
|
529
|
+
* uri: 'incoming 分支的 uri'
|
|
530
|
+
* },
|
|
531
|
+
* output: '中间视图的文件 uri',
|
|
532
|
+
* base: '共同祖先分支的文件 uri'
|
|
533
|
+
* }
|
|
534
|
+
*/
|
|
535
|
+
|
|
536
|
+
this.commandService.executeCommand(EDITOR_COMMANDS.OPEN_MERGEEDITOR.id, toArgs);
|
|
537
|
+
} catch (error) {}
|
|
538
|
+
},
|
|
539
|
+
});
|
|
540
|
+
|
|
505
541
|
commands.registerCommand(EDITOR_COMMANDS.OPEN_MERGEEDITOR, {
|
|
506
542
|
execute: (args: unknown) => {
|
|
507
543
|
const validatedArgs = IRelaxedOpenMergeEditorArgs.validate(args);
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
2
|
import { Disposable, IDisposable, IEventBus, URI } from '@opensumi/ide-core-browser';
|
|
3
|
+
import * as monaco from '@opensumi/ide-monaco';
|
|
3
4
|
import { IIconService, IThemeService } from '@opensumi/ide-theme';
|
|
4
5
|
import { ICSSStyleService } from '@opensumi/ide-theme/lib/common/style';
|
|
5
|
-
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
|
|
6
6
|
|
|
7
7
|
import { IContentDecorationRenderOptions, IDecorationRenderOptions, IThemeDecorationRenderOptions } from '../common';
|
|
8
8
|
|
|
@@ -571,8 +571,54 @@
|
|
|
571
571
|
|
|
572
572
|
// -------------- styles for merge editor component starts --------------
|
|
573
573
|
.merge_editor_float_container {
|
|
574
|
-
|
|
575
|
-
|
|
576
|
-
|
|
574
|
+
display: flex;
|
|
575
|
+
background: var(--kt-panelTab-activeBackground);
|
|
576
|
+
box-shadow: inset 1px 1px 3px 0px var(--kt-panelTab-border);
|
|
577
|
+
padding: 16px 28px;
|
|
578
|
+
justify-content: end;
|
|
579
|
+
white-space: nowrap;
|
|
580
|
+
.merge_conflict_bottom_btn {
|
|
581
|
+
border: 1px solid var(--kt-button-disableForeground);
|
|
582
|
+
border-radius: 8px;
|
|
583
|
+
padding: 5px 16px;
|
|
584
|
+
background: var(--editor-background);
|
|
585
|
+
margin: 0 4px;
|
|
586
|
+
line-height: 22px;
|
|
587
|
+
justify-content: end;
|
|
588
|
+
white-space: nowrap;
|
|
589
|
+
cursor: pointer;
|
|
590
|
+
:global {
|
|
591
|
+
.kt-icon {
|
|
592
|
+
font-size: 12px;
|
|
593
|
+
}
|
|
594
|
+
}
|
|
595
|
+
:first-child {
|
|
596
|
+
margin-right: 8px;
|
|
597
|
+
}
|
|
598
|
+
}
|
|
599
|
+
|
|
600
|
+
.magic_btn {
|
|
601
|
+
background-image: radial-gradient(circle at -21% -22%, #19cfff, #8429ff);
|
|
602
|
+
border: none;
|
|
603
|
+
font-weight: 500;
|
|
604
|
+
span {
|
|
605
|
+
color: #fff;
|
|
606
|
+
}
|
|
607
|
+
:global {
|
|
608
|
+
.kt-icon {
|
|
609
|
+
color: #fff;
|
|
610
|
+
font-size: 12px;
|
|
611
|
+
margin-right: 8px;
|
|
612
|
+
}
|
|
613
|
+
}
|
|
614
|
+
}
|
|
615
|
+
|
|
616
|
+
.line_vertical {
|
|
617
|
+
background-color: var(--design-border-color-common);
|
|
618
|
+
width: 1px;
|
|
619
|
+
min-width: 1px;
|
|
620
|
+
height: 24px;
|
|
621
|
+
margin: 4px;
|
|
622
|
+
}
|
|
577
623
|
}
|
|
578
624
|
// -------------- styles for merge editor component ends --------------
|
|
@@ -1,13 +1,15 @@
|
|
|
1
1
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
2
|
import { PreferenceService } from '@opensumi/ide-core-browser';
|
|
3
3
|
import { IRange, URI } from '@opensumi/ide-core-common';
|
|
4
|
+
import * as monaco from '@opensumi/ide-monaco';
|
|
5
|
+
import { isEqual } from '@opensumi/monaco-editor-core/esm/vs/base/common/resources';
|
|
4
6
|
import { AbstractCodeEditorService } from '@opensumi/monaco-editor-core/esm/vs/editor/browser/services/abstractCodeEditorService';
|
|
5
7
|
import { ICodeEditorService } from '@opensumi/monaco-editor-core/esm/vs/editor/browser/services/codeEditorService';
|
|
6
|
-
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
|
|
7
8
|
import { EditorScopedLayoutService } from '@opensumi/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneLayoutService';
|
|
8
9
|
import { StandaloneServices } from '@opensumi/monaco-editor-core/esm/vs/editor/standalone/browser/standaloneServices';
|
|
9
10
|
import { IStandaloneThemeService } from '@opensumi/monaco-editor-core/esm/vs/editor/standalone/common/standaloneTheme';
|
|
10
11
|
import { ContextViewService } from '@opensumi/monaco-editor-core/esm/vs/platform/contextview/browser/contextViewService';
|
|
12
|
+
import { IResourceEditorInput } from '@opensumi/monaco-editor-core/esm/vs/platform/editor/common/editor';
|
|
11
13
|
|
|
12
14
|
/* istanbul ignore file */
|
|
13
15
|
import { EditorOpenType, WorkbenchEditorService } from '../common';
|
|
@@ -44,22 +46,17 @@ export class MonacoCodeService extends AbstractCodeEditorService {
|
|
|
44
46
|
* @param sideBySide ?
|
|
45
47
|
*/
|
|
46
48
|
async openCodeEditor(
|
|
47
|
-
|
|
48
|
-
input: monaco.editor.IResourceInput,
|
|
49
|
+
input: IResourceEditorInput,
|
|
49
50
|
source: IMonacoCodeEditor | null,
|
|
50
51
|
sideBySide?: boolean,
|
|
51
52
|
): Promise<IMonacoCodeEditor | null> {
|
|
52
|
-
const resourceUri =
|
|
53
|
+
const resourceUri = input.resource;
|
|
53
54
|
// 判断打开下一个不同于当前编辑器的文件时,是否需要先固定当前编辑器Tab,从而避免被替换,例如:跳转到定义
|
|
54
55
|
const enablePreviewFromCodeNavigation = this.preferenceService.get<boolean>(
|
|
55
56
|
'editor.enablePreviewFromCodeNavigation',
|
|
56
57
|
);
|
|
57
|
-
|
|
58
|
-
|
|
59
|
-
source &&
|
|
60
|
-
!sideBySide &&
|
|
61
|
-
!new URI(source.getModel()?.uri).isEqual(input.resource)
|
|
62
|
-
) {
|
|
58
|
+
|
|
59
|
+
if (!enablePreviewFromCodeNavigation && source && !sideBySide && isEqual(source.getModel()?.uri, input.resource)) {
|
|
63
60
|
for (const visibleGroup of this.workbenchEditorService.editorGroups) {
|
|
64
61
|
if (visibleGroup.currentOpenType?.type === EditorOpenType.code) {
|
|
65
62
|
if (visibleGroup.currentEditor?.monacoEditor === source) {
|
|
@@ -91,6 +88,7 @@ export class MonacoCodeService extends AbstractCodeEditorService {
|
|
|
91
88
|
index++;
|
|
92
89
|
}
|
|
93
90
|
}
|
|
91
|
+
// @ts-ignore
|
|
94
92
|
const selection = input.options ? input.options.selection : null;
|
|
95
93
|
let range;
|
|
96
94
|
if (selection) {
|
|
@@ -105,13 +103,12 @@ export class MonacoCodeService extends AbstractCodeEditorService {
|
|
|
105
103
|
);
|
|
106
104
|
}
|
|
107
105
|
}
|
|
108
|
-
|
|
106
|
+
const openUri = URI.parse(resourceUri.toString());
|
|
107
|
+
await editorGroup.open(openUri, { index, range: range as IRange, focus: true });
|
|
109
108
|
return (editorGroup.codeEditor as BrowserCodeEditor).monacoEditor;
|
|
110
109
|
}
|
|
111
110
|
}
|
|
112
111
|
|
|
113
|
-
// @ts-ignore
|
|
114
|
-
|
|
115
112
|
export class MonacoContextViewService extends ContextViewService {
|
|
116
113
|
private menuContainer: HTMLDivElement;
|
|
117
114
|
|
|
@@ -1,8 +1,8 @@
|
|
|
1
1
|
import { Autowired, Injectable } from '@opensumi/di';
|
|
2
2
|
import { PreferenceScope, PreferenceService, QuickPickService, URI, localize } from '@opensumi/ide-core-browser';
|
|
3
|
+
import * as monaco from '@opensumi/ide-monaco';
|
|
3
4
|
import { ITextModel } from '@opensumi/ide-monaco/lib/browser/monaco-api/types';
|
|
4
5
|
import { FormattingMode } from '@opensumi/monaco-editor-core/esm/vs/editor/contrib/format/browser/format';
|
|
5
|
-
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
|
|
6
6
|
|
|
7
7
|
import { IEditorDocumentModelService } from '../doc-model/types';
|
|
8
8
|
|
|
@@ -45,7 +45,7 @@ export class FormattingSelector {
|
|
|
45
45
|
const elements: { [key: string]: IProvider } = {};
|
|
46
46
|
formatters.forEach((provider: IProvider) => {
|
|
47
47
|
if (provider.extensionId) {
|
|
48
|
-
elements[provider.extensionId] = provider;
|
|
48
|
+
elements[provider.extensionId as any] = provider;
|
|
49
49
|
}
|
|
50
50
|
});
|
|
51
51
|
|
|
@@ -73,7 +73,7 @@ export class FormattingSelector {
|
|
|
73
73
|
{ ...config, [languageId]: selected },
|
|
74
74
|
PreferenceScope.User,
|
|
75
75
|
);
|
|
76
|
-
return elements[selected];
|
|
76
|
+
return elements[selected as any];
|
|
77
77
|
}
|
|
78
78
|
} else {
|
|
79
79
|
return undefined;
|
|
@@ -1,14 +1,12 @@
|
|
|
1
|
-
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
|
|
2
|
-
|
|
3
|
-
import IMonacoModel = monaco.editor.IModel;
|
|
4
|
-
import IMonacoMarkerData = monaco.editor.IMarkerData;
|
|
5
|
-
|
|
6
|
-
// eslint-disable-next-line import/order
|
|
7
1
|
import { Disposable, DisposableCollection, IDisposable } from '@opensumi/ide-core-common';
|
|
2
|
+
import * as monaco from '@opensumi/ide-monaco';
|
|
3
|
+
import { monacoApi } from '@opensumi/ide-monaco/lib/browser/monaco-api';
|
|
8
4
|
|
|
9
|
-
// eslint-disable-next-line import/order
|
|
10
5
|
import { Diagnostic, DiagnosticCollection, asMonacoDiagnostics } from '../../common';
|
|
11
6
|
|
|
7
|
+
type IMonacoModel = monaco.editor.ITextModel;
|
|
8
|
+
type IMonacoMarkerData = monaco.editor.IMarkerData;
|
|
9
|
+
|
|
12
10
|
export class MonacoDiagnosticCollection implements DiagnosticCollection {
|
|
13
11
|
protected readonly diagnostics = new Map<string, MonacoModelDiagnostics | undefined>();
|
|
14
12
|
protected readonly toDispose = new DisposableCollection();
|
|
@@ -48,7 +46,7 @@ export class MonacoModelDiagnostics implements IDisposable {
|
|
|
48
46
|
constructor(uri: string, diagnostics: Diagnostic[], readonly owner: string) {
|
|
49
47
|
this.uri = monaco.Uri.parse(uri);
|
|
50
48
|
this.diagnostics = diagnostics;
|
|
51
|
-
|
|
49
|
+
monacoApi.editor.onDidCreateModel((model) => this.doUpdateModelMarkers(model));
|
|
52
50
|
}
|
|
53
51
|
|
|
54
52
|
set diagnostics(diagnostics: Diagnostic[]) {
|
|
@@ -71,13 +69,13 @@ export class MonacoModelDiagnostics implements IDisposable {
|
|
|
71
69
|
}
|
|
72
70
|
|
|
73
71
|
updateModelMarkers(): void {
|
|
74
|
-
const model =
|
|
72
|
+
const model = monacoApi.editor.getModel(this.uri);
|
|
75
73
|
this.doUpdateModelMarkers(model);
|
|
76
74
|
}
|
|
77
75
|
|
|
78
76
|
protected doUpdateModelMarkers(model: IMonacoModel | null): void {
|
|
79
77
|
if (model && this.uri.toString() === model.uri.toString()) {
|
|
80
|
-
|
|
78
|
+
monacoApi.editor.setModelMarkers(model, this.owner, this._markers);
|
|
81
79
|
}
|
|
82
80
|
}
|
|
83
81
|
}
|
|
@@ -8,8 +8,8 @@ import {
|
|
|
8
8
|
MarkerSeverity,
|
|
9
9
|
URI,
|
|
10
10
|
} from '@opensumi/ide-core-common';
|
|
11
|
+
import * as monaco from '@opensumi/ide-monaco';
|
|
11
12
|
import { ITextmateTokenizer, ITextmateTokenizerService } from '@opensumi/ide-monaco/lib/browser/contrib/tokenizer';
|
|
12
|
-
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
|
|
13
13
|
|
|
14
14
|
import {
|
|
15
15
|
Diagnostic,
|
|
@@ -1,5 +1,6 @@
|
|
|
1
1
|
import { Disposable, IContextKeyService } from '@opensumi/ide-core-browser';
|
|
2
2
|
import { AbstractContextMenuService, ICtxMenuRenderer, MenuId } from '@opensumi/ide-core-browser/lib/menu/next';
|
|
3
|
+
import * as monaco from '@opensumi/ide-monaco';
|
|
3
4
|
import { ICodeEditor } from '@opensumi/ide-monaco/lib/common/types';
|
|
4
5
|
import * as dom from '@opensumi/monaco-editor-core/esm/vs/base/browser/dom';
|
|
5
6
|
import { IAnchor } from '@opensumi/monaco-editor-core/esm/vs/base/browser/ui/contextview/contextview';
|
|
@@ -8,7 +9,6 @@ import { IEditorMouseEvent, MouseTargetType } from '@opensumi/monaco-editor-core
|
|
|
8
9
|
import { EditorOption } from '@opensumi/monaco-editor-core/esm/vs/editor/common/config/editorOptions';
|
|
9
10
|
import { IEditorContribution } from '@opensumi/monaco-editor-core/esm/vs/editor/common/editorCommon';
|
|
10
11
|
import { ContextMenuController } from '@opensumi/monaco-editor-core/esm/vs/editor/contrib/contextmenu/browser/contextmenu';
|
|
11
|
-
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
|
|
12
12
|
|
|
13
13
|
export class EditorContextMenuController extends Disposable implements IEditorContribution {
|
|
14
14
|
public static readonly ID = 'editor.contrib.contextmenu';
|
|
@@ -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
|
}
|
|
@@ -17,13 +17,12 @@ import {
|
|
|
17
17
|
IncomingCall,
|
|
18
18
|
OutgoingCall,
|
|
19
19
|
} from '@opensumi/ide-monaco/lib/browser/contrib/callHierarchy';
|
|
20
|
-
import { ITextModel, Position } from '@opensumi/ide-monaco/lib/browser/monaco-api/types';
|
|
20
|
+
import { ITextModel, Position, ProviderResult } from '@opensumi/ide-monaco/lib/browser/monaco-api/types';
|
|
21
21
|
|
|
22
22
|
import { IEditorDocumentModelService } from '../../doc-model/types';
|
|
23
23
|
|
|
24
24
|
const { isNonEmptyArray } = arrays;
|
|
25
25
|
|
|
26
|
-
declare type ProviderResult<T> = T | undefined | null | Thenable<T | undefined | null>;
|
|
27
26
|
/* ---------------------------------------------------------------------------------------------
|
|
28
27
|
* Copyright (c) Microsoft Corporation. All rights reserved.
|
|
29
28
|
* Licensed under the MIT License. See License.txt in the project root for license information.
|
|
@@ -205,7 +205,7 @@ export class MonacoCommandRegistry implements IMonacoCommandsRegistry {
|
|
|
205
205
|
* 获取当前活动的编辑器
|
|
206
206
|
* 此处的活动编辑器和 workbenchEditorService.currentEditor 的概念不同,对于diffEditor,需要获取确实的那个editor而不是modifiedEditor
|
|
207
207
|
*/
|
|
208
|
-
|
|
208
|
+
public getActiveCodeEditor(): ICodeEditor | undefined {
|
|
209
209
|
// 先从 monaco 内部获取到当前 focus 的 editor
|
|
210
210
|
const editor = this.codeEditorService?.getFocusedCodeEditor();
|
|
211
211
|
if (editor) {
|
|
@@ -290,7 +290,7 @@ export class MonacoActionRegistry implements IMonacoActionRegistry {
|
|
|
290
290
|
|
|
291
291
|
registerMonacoActions() {
|
|
292
292
|
const editorActions = new Map(
|
|
293
|
-
this.monacoEditorRegistry.getEditorActions().map(({ id, label, alias }) => [
|
|
293
|
+
Array.from(this.monacoEditorRegistry.getEditorActions()).map(({ id, label, alias }) => [
|
|
294
294
|
id,
|
|
295
295
|
{
|
|
296
296
|
label,
|
|
@@ -1,11 +1,11 @@
|
|
|
1
1
|
import { IGrammar, INITIAL, StackElement } from 'vscode-textmate';
|
|
2
2
|
|
|
3
3
|
import { Disposable, Emitter, Event } from '@opensumi/ide-core-common/lib/utils';
|
|
4
|
+
import * as monaco from '@opensumi/ide-monaco';
|
|
4
5
|
import {
|
|
5
6
|
MetadataConsts,
|
|
6
7
|
TokenMetadata,
|
|
7
8
|
} from '@opensumi/monaco-editor-core/esm/vs/editor/common/encodedTokenAttributes';
|
|
8
|
-
import * as monaco from '@opensumi/monaco-editor-core/esm/vs/editor/editor.api';
|
|
9
9
|
|
|
10
10
|
export class TokenizerState implements monaco.languages.IState {
|
|
11
11
|
constructor(public readonly ruleStack: StackElement) {}
|