Welcome to mirror list, hosted at ThFree Co, Russian Federation.

github.com/microsoft/vscode.git - Unnamed repository; edit this file 'description' to name the repository.
summaryrefslogtreecommitdiff
diff options
context:
space:
mode:
Diffstat (limited to 'src/vs/workbench/common/editor.ts')
-rw-r--r--src/vs/workbench/common/editor.ts68
1 files changed, 63 insertions, 5 deletions
diff --git a/src/vs/workbench/common/editor.ts b/src/vs/workbench/common/editor.ts
index 03fd014d39b..6f6ab509248 100644
--- a/src/vs/workbench/common/editor.ts
+++ b/src/vs/workbench/common/editor.ts
@@ -484,6 +484,36 @@ export interface IResourceDiffEditorInput extends IBaseUntypedEditorInput {
readonly modified: IResourceEditorInput | ITextResourceEditorInput | IUntitledTextResourceEditorInput;
}
+/**
+ * A resource merge editor input compares multiple editors
+ * highlighting the differences for merging.
+ *
+ * Note: all sides must be resolvable to the same editor, or
+ * a text based presentation will be used as fallback.
+ */
+export interface IResourceMergeEditorInput extends IBaseUntypedEditorInput {
+
+ /**
+ * The one changed version of the file.
+ */
+ readonly input1: IResourceEditorInput | ITextResourceEditorInput;
+
+ /**
+ * The second changed version of the file.
+ */
+ readonly input2: IResourceEditorInput | ITextResourceEditorInput;
+
+ /**
+ * The base common ancestor of the file to merge.
+ */
+ readonly base: IResourceEditorInput | ITextResourceEditorInput;
+
+ /**
+ * The resulting output of the merge.
+ */
+ readonly result: IResourceEditorInput | ITextResourceEditorInput;
+}
+
export function isResourceEditorInput(editor: unknown): editor is IResourceEditorInput {
if (isEditorInput(editor)) {
return false; // make sure to not accidentally match on typed editor inputs
@@ -531,6 +561,16 @@ export function isUntitledResourceEditorInput(editor: unknown): editor is IUntit
return candidate.resource === undefined || candidate.resource.scheme === Schemas.untitled || candidate.forceUntitled === true;
}
+export function isResourceMergeEditorInput(editor: unknown): editor is IResourceMergeEditorInput {
+ if (isEditorInput(editor)) {
+ return false; // make sure to not accidentally match on typed editor inputs
+ }
+
+ const candidate = editor as IResourceMergeEditorInput | undefined;
+
+ return URI.isUri(candidate?.base?.resource) && URI.isUri(candidate?.input1?.resource) && URI.isUri(candidate?.input2?.resource) && URI.isUri(candidate?.result?.resource);
+}
+
export const enum Verbosity {
SHORT,
MEDIUM,
@@ -693,9 +733,15 @@ export const enum EditorInputCapabilities {
* editor by holding shift.
*/
CanDropIntoEditor = 1 << 7,
+
+ /**
+ * Signals that the editor is composed of multiple editors
+ * within.
+ */
+ MultipleEditors = 1 << 8
}
-export type IUntypedEditorInput = IResourceEditorInput | ITextResourceEditorInput | IUntitledTextResourceEditorInput | IResourceDiffEditorInput | IResourceSideBySideEditorInput;
+export type IUntypedEditorInput = IResourceEditorInput | ITextResourceEditorInput | IUntitledTextResourceEditorInput | IResourceDiffEditorInput | IResourceSideBySideEditorInput | IResourceMergeEditorInput;
export abstract class AbstractEditorInput extends Disposable {
// Marker class for implementing `isEditorInput`
@@ -1114,11 +1160,17 @@ class EditorResourceAccessorImpl {
getOriginalUri(editor: EditorInput | IUntypedEditorInput | undefined | null): URI | undefined;
getOriginalUri(editor: EditorInput | IUntypedEditorInput | undefined | null, options: IEditorResourceAccessorOptions & { supportSideBySide?: SideBySideEditor.PRIMARY | SideBySideEditor.SECONDARY | SideBySideEditor.ANY }): URI | undefined;
getOriginalUri(editor: EditorInput | IUntypedEditorInput | undefined | null, options: IEditorResourceAccessorOptions & { supportSideBySide: SideBySideEditor.BOTH }): URI | { primary?: URI; secondary?: URI } | undefined;
+ getOriginalUri(editor: EditorInput | IUntypedEditorInput | undefined | null, options?: IEditorResourceAccessorOptions): URI | { primary?: URI; secondary?: URI } | undefined;
getOriginalUri(editor: EditorInput | IUntypedEditorInput | undefined | null, options?: IEditorResourceAccessorOptions): URI | { primary?: URI; secondary?: URI } | undefined {
if (!editor) {
return undefined;
}
+ // Merge editors are handled with `merged` result editor
+ if (isResourceMergeEditorInput(editor)) {
+ return EditorResourceAccessor.getOriginalUri(editor.result, options);
+ }
+
// Optionally support side-by-side editors
if (options?.supportSideBySide) {
const { primary, secondary } = this.getSideEditors(editor);
@@ -1136,8 +1188,8 @@ class EditorResourceAccessorImpl {
}
}
- if (isResourceDiffEditorInput(editor) || isResourceSideBySideEditorInput(editor)) {
- return;
+ if (isResourceDiffEditorInput(editor) || isResourceSideBySideEditorInput(editor) || isResourceMergeEditorInput(editor)) {
+ return undefined;
}
// Original URI is the `preferredResource` of an editor if any
@@ -1177,11 +1229,17 @@ class EditorResourceAccessorImpl {
getCanonicalUri(editor: EditorInput | IUntypedEditorInput | undefined | null): URI | undefined;
getCanonicalUri(editor: EditorInput | IUntypedEditorInput | undefined | null, options: IEditorResourceAccessorOptions & { supportSideBySide?: SideBySideEditor.PRIMARY | SideBySideEditor.SECONDARY | SideBySideEditor.ANY }): URI | undefined;
getCanonicalUri(editor: EditorInput | IUntypedEditorInput | undefined | null, options: IEditorResourceAccessorOptions & { supportSideBySide: SideBySideEditor.BOTH }): URI | { primary?: URI; secondary?: URI } | undefined;
+ getCanonicalUri(editor: EditorInput | IUntypedEditorInput | undefined | null, options?: IEditorResourceAccessorOptions): URI | { primary?: URI; secondary?: URI } | undefined;
getCanonicalUri(editor: EditorInput | IUntypedEditorInput | undefined | null, options?: IEditorResourceAccessorOptions): URI | { primary?: URI; secondary?: URI } | undefined {
if (!editor) {
return undefined;
}
+ // Merge editors are handled with `merged` result editor
+ if (isResourceMergeEditorInput(editor)) {
+ return EditorResourceAccessor.getCanonicalUri(editor.result, options);
+ }
+
// Optionally support side-by-side editors
if (options?.supportSideBySide) {
const { primary, secondary } = this.getSideEditors(editor);
@@ -1199,8 +1257,8 @@ class EditorResourceAccessorImpl {
}
}
- if (isResourceDiffEditorInput(editor) || isResourceSideBySideEditorInput(editor)) {
- return;
+ if (isResourceDiffEditorInput(editor) || isResourceSideBySideEditorInput(editor) || isResourceMergeEditorInput(editor)) {
+ return undefined;
}
// Canonical URI is the `resource` of an editor