Update to VS Code 1.52.1

This commit is contained in:
Asher
2021-02-09 16:08:37 +00:00
1351 changed files with 56560 additions and 38990 deletions

View File

@@ -3,7 +3,7 @@
* Licensed under the MIT License. See License.txt in the project root for license information.
*--------------------------------------------------------------------------------------------*/
import { ICodeEditor, isCodeEditor, isDiffEditor, isCompositeEditor } from 'vs/editor/browser/editorBrowser';
import { ICodeEditor, isCodeEditor, isDiffEditor, isCompositeEditor, getCodeEditor } from 'vs/editor/browser/editorBrowser';
import { CodeEditorServiceImpl } from 'vs/editor/browser/services/codeEditorServiceImpl';
import { ScrollType } from 'vs/editor/common/editorCommon';
import { IResourceEditorInput } from 'vs/platform/editor/common/editor';
@@ -69,12 +69,34 @@ export class CodeEditorService extends CodeEditorServiceImpl {
}
private async doOpenCodeEditor(input: IResourceEditorInput, source: ICodeEditor | null, sideBySide?: boolean): Promise<ICodeEditor | null> {
// Special case: we want to detect the request to open an editor that
// is different from the current one to decide wether the current editor
// should be pinned or not. This ensures that the source of a navigation
// is not being replaced by the target. An example is "Goto definition"
// that otherwise would replace the editor everytime the user navigates.
if (
source && // we need to know the origin of the navigation
!input.options?.pinned && // we only need to look at preview editors that open
!sideBySide && // we only need to care if editor opens in same group
!isEqual(source.getModel()?.uri, input.resource) // we only need to do this if the editor is about to change
) {
for (const visiblePane of this.editorService.visibleEditorPanes) {
if (getCodeEditor(visiblePane.getControl()) === source) {
visiblePane.group.pinEditor();
break;
}
}
}
// Open as editor
const control = await this.editorService.openEditor(input, sideBySide ? SIDE_GROUP : ACTIVE_GROUP);
if (control) {
const widget = control.getControl();
if (isCodeEditor(widget)) {
return widget;
}
if (isCompositeEditor(widget) && isCodeEditor(widget.activeCodeEditor)) {
return widget.activeCodeEditor;
}

View File

@@ -24,7 +24,6 @@ import { Disposable, IDisposable, dispose, toDisposable, DisposableStore } from
import { coalesce, distinct, insert } from 'vs/base/common/arrays';
import { isCodeEditor, isDiffEditor, ICodeEditor, IDiffEditor, isCompositeEditor } from 'vs/editor/browser/editorBrowser';
import { IEditorGroupView, IEditorOpeningEvent, EditorServiceImpl } from 'vs/workbench/browser/parts/editor/editor';
import { ILabelService } from 'vs/platform/label/common/label';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
import { withNullAsUndefined } from 'vs/base/common/types';
import { EditorsObserver } from 'vs/workbench/browser/parts/editor/editorsObserver';
@@ -73,7 +72,6 @@ export class EditorService extends Disposable implements EditorServiceImpl {
@IEditorGroupsService private readonly editorGroupService: IEditorGroupsService,
@IUntitledTextEditorService private readonly untitledTextEditorService: IUntitledTextEditorService,
@IInstantiationService private readonly instantiationService: IInstantiationService,
@ILabelService private readonly labelService: ILabelService,
@IFileService private readonly fileService: IFileService,
@IConfigurationService private readonly configurationService: IConfigurationService,
@IWorkspaceContextService private readonly contextService: IWorkspaceContextService,
@@ -817,11 +815,12 @@ export class EditorService extends Disposable implements EditorServiceImpl {
const leftInput = this.createEditorInput({ resource: resourceDiffInput.leftResource, forceFile: resourceDiffInput.forceFile });
const rightInput = this.createEditorInput({ resource: resourceDiffInput.rightResource, forceFile: resourceDiffInput.forceFile });
return new DiffEditorInput(
resourceDiffInput.label || this.toSideBySideLabel(leftInput, rightInput),
return this.instantiationService.createInstance(DiffEditorInput,
resourceDiffInput.label,
resourceDiffInput.description,
leftInput,
rightInput
rightInput,
undefined
);
}
@@ -881,7 +880,7 @@ export class EditorService extends Disposable implements EditorServiceImpl {
// File
if (resourceEditorInput.forceFile || this.fileService.canHandleResource(canonicalResource)) {
return this.fileEditorInputFactory.createFileEditorInput(canonicalResource, preferredResource, resourceEditorInput.encoding, resourceEditorInput.mode, this.instantiationService);
return this.fileEditorInputFactory.createFileEditorInput(canonicalResource, preferredResource, resourceEditorInput.label, resourceEditorInput.description, resourceEditorInput.encoding, resourceEditorInput.mode, this.instantiationService);
}
// Resource
@@ -897,6 +896,14 @@ export class EditorService extends Disposable implements EditorServiceImpl {
else if (!(cachedInput instanceof ResourceEditorInput)) {
cachedInput.setPreferredResource(preferredResource);
if (resourceEditorInput.label) {
cachedInput.setPreferredName(resourceEditorInput.label);
}
if (resourceEditorInput.description) {
cachedInput.setPreferredDescription(resourceEditorInput.description);
}
if (resourceEditorInput.encoding) {
cachedInput.setPreferredEncoding(resourceEditorInput.encoding);
}
@@ -968,19 +975,6 @@ export class EditorService extends Disposable implements EditorServiceImpl {
return input;
}
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 })} ↔ ${this.labelService.getUriLabel(rightInput.preferredResource, { relative: true })}`;
}
// Signal back that the label should be computed from within the editor
return undefined;
}
//#endregion
//#region save/revert

View File

@@ -21,16 +21,6 @@ export const enum GroupDirection {
RIGHT
}
export function preferredSideBySideGroupDirection(configurationService: IConfigurationService): GroupDirection.DOWN | GroupDirection.RIGHT {
const openSideBySideDirection = configurationService.getValue<'right' | 'down'>('workbench.editor.openSideBySideDirection');
if (openSideBySideDirection === 'down') {
return GroupDirection.DOWN;
}
return GroupDirection.RIGHT;
}
export const enum GroupOrientation {
HORIZONTAL,
VERTICAL
@@ -595,3 +585,18 @@ export interface IEditorGroup {
*/
focus(): void;
}
//#region Editor Group Helpers
export function preferredSideBySideGroupDirection(configurationService: IConfigurationService): GroupDirection.DOWN | GroupDirection.RIGHT {
const openSideBySideDirection = configurationService.getValue<'right' | 'down'>('workbench.editor.openSideBySideDirection');
if (openSideBySideDirection === 'down') {
return GroupDirection.DOWN;
}
return GroupDirection.RIGHT;
}
//#endregion

View File

@@ -16,6 +16,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { IQuickInputService, IQuickPickItem } from 'vs/platform/quickinput/common/quickInput';
import { URI } from 'vs/base/common/uri';
import { extname, basename, isEqual } from 'vs/base/common/resources';
import { Codicon } from 'vs/base/common/codicons';
/**
* Id of the default editor for open with.
@@ -71,7 +72,7 @@ export async function openEditorWith(
description: entry.active ? nls.localize('promptOpenWith.currentlyActive', 'Currently Active') : undefined,
detail: entry.detail,
buttons: resourceExt ? [{
iconClass: 'codicon-settings-gear',
iconClass: Codicon.gear.classNames,
tooltip: nls.localize('promptOpenWith.setDefaultTooltip', "Set as default editor for '{0}' files", resourceExt)
}] : undefined
};

View File

@@ -298,7 +298,7 @@ suite('EditorsObserver', function () {
assert.equal(observer.hasEditor(input2.resource), true);
assert.equal(observer.hasEditor(input3.resource), true);
storage._onWillSaveState.fire({ reason: WillSaveStateReason.SHUTDOWN });
storage.emitWillSaveState(WillSaveStateReason.SHUTDOWN);
const restoredObserver = new EditorsObserver(part, storage);
await part.whenRestored;
@@ -350,7 +350,7 @@ suite('EditorsObserver', function () {
assert.equal(observer.hasEditor(input2.resource), true);
assert.equal(observer.hasEditor(input3.resource), true);
storage._onWillSaveState.fire({ reason: WillSaveStateReason.SHUTDOWN });
storage.emitWillSaveState(WillSaveStateReason.SHUTDOWN);
const restoredObserver = new EditorsObserver(part, storage);
await part.whenRestored;
@@ -390,7 +390,7 @@ suite('EditorsObserver', function () {
assert.equal(currentEditorsMRU[0].editor, input1);
assert.equal(observer.hasEditor(input1.resource), true);
storage._onWillSaveState.fire({ reason: WillSaveStateReason.SHUTDOWN });
storage.emitWillSaveState(WillSaveStateReason.SHUTDOWN);
const restoredObserver = new EditorsObserver(part, storage);
await part.whenRestored;