mirror of
https://github.com/microsoft/vscode.git
synced 2026-09-23 15:24:20 +01:00
editors - let the diff editor compute a good name
This commit is contained in:
@@ -3,7 +3,6 @@
|
||||
* Licensed under the MIT License. See License.txt in the project root for license information.
|
||||
*--------------------------------------------------------------------------------------------*/
|
||||
|
||||
import { localize } from 'vs/nls';
|
||||
import { disposed } from 'vs/base/common/errors';
|
||||
import { IDisposable, dispose, DisposableStore } from 'vs/base/common/lifecycle';
|
||||
import { equals as objectEquals } from 'vs/base/common/objects';
|
||||
@@ -348,10 +347,6 @@ CommandsRegistry.registerCommand('_workbench.diff', async function (accessor: Se
|
||||
};
|
||||
}
|
||||
|
||||
if (!label) {
|
||||
label = localize('diffLeftRightLabel', "{0} ⟷ {1}", leftResource.toString(true), rightResource.toString(true));
|
||||
}
|
||||
|
||||
await editorService.openEditor({ leftResource, rightResource, label, description, options }, viewColumnToEditorGroup(editorGroupService, position));
|
||||
});
|
||||
|
||||
|
||||
@@ -818,7 +818,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
||||
const rightInput = this.createEditorInput({ resource: resourceDiffInput.rightResource, forceFile: resourceDiffInput.forceFile });
|
||||
|
||||
return new DiffEditorInput(
|
||||
resourceDiffInput.label || this.toSideBySideLabel(leftInput, rightInput, '↔'),
|
||||
resourceDiffInput.label || this.toSideBySideLabel(leftInput, rightInput),
|
||||
resourceDiffInput.description,
|
||||
leftInput,
|
||||
rightInput
|
||||
@@ -968,18 +968,13 @@ export class EditorService extends Disposable implements EditorServiceImpl {
|
||||
return input;
|
||||
}
|
||||
|
||||
private toSideBySideLabel(leftInput: EditorInput, rightInput: EditorInput, divider: string): string | undefined {
|
||||
|
||||
// Without any resource, do not try to compute a label
|
||||
if (!leftInput.resource || !rightInput.resource) {
|
||||
return undefined;
|
||||
}
|
||||
private toSideBySideLabel(leftInput: EditorInput, rightInput: EditorInput): string | undefined {
|
||||
|
||||
// If both editors are file inputs, we produce an optimized label
|
||||
// by adding the relative path of both inputs to the label. This
|
||||
// makes it easier to understand a file-based comparison.
|
||||
if (this.fileEditorInputFactory.isFileEditorInput(leftInput) && this.fileEditorInputFactory.isFileEditorInput(rightInput)) {
|
||||
return `${this.labelService.getUriLabel(leftInput.preferredResource, { relative: true })} ${divider} ${this.labelService.getUriLabel(rightInput.preferredResource, { relative: true })}`;
|
||||
return `${this.labelService.getUriLabel(leftInput.preferredResource, { relative: true })} ↔ ${this.labelService.getUriLabel(rightInput.preferredResource, { relative: true })}`;
|
||||
}
|
||||
|
||||
// Signal back that the label should be computed from within the editor
|
||||
|
||||
Reference in New Issue
Block a user