Merge from vscode 2b0b9136329c181a9e381463a1f7dc3a2d105a34 (#4880)

This commit is contained in:
Karl Burtram
2019-04-05 10:09:18 -07:00
committed by GitHub
parent 9bd7e30d18
commit cb5bcf2248
433 changed files with 8915 additions and 8361 deletions

View File

@@ -248,7 +248,7 @@ export class EditorMemento<T> implements IEditorMemento<T> {
}
}
private doGetResource(resourceOrEditor: URI | EditorInput): URI | null {
private doGetResource(resourceOrEditor: URI | EditorInput): URI | undefined {
if (resourceOrEditor instanceof EditorInput) {
return resourceOrEditor.getResource();
}

View File

@@ -40,7 +40,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
private metadata: string | undefined;
private binaryContainer: HTMLElement;
private scrollbar: DomScrollableElement;
private resourceViewerContext: ResourceViewerContext;
private resourceViewerContext: ResourceViewerContext | undefined;
constructor(
id: string,
@@ -127,7 +127,8 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
// Clear Resource Viewer
clearNode(this.binaryContainer);
this.resourceViewerContext = dispose(this.resourceViewerContext);
dispose(this.resourceViewerContext);
this.resourceViewerContext = undefined;
super.clearInput();
}
@@ -149,7 +150,8 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
dispose(): void {
this.binaryContainer.remove();
this.resourceViewerContext = dispose(this.resourceViewerContext);
dispose(this.resourceViewerContext);
this.resourceViewerContext = undefined;
super.dispose();
}

View File

@@ -30,7 +30,7 @@ export class ExecuteCommandAction extends Action {
label: string,
private commandId: string,
private commandService: ICommandService,
private commandArgs?: any
private commandArgs?: unknown
) {
super(id, label);
}
@@ -429,14 +429,16 @@ export class OpenToSideFromQuickOpenAction extends Action {
const entry = toEditorQuickOpenEntry(context);
if (entry) {
const input = entry.getInput();
if (input instanceof EditorInput) {
return this.editorService.openEditor(input, entry.getOptions() || undefined, SIDE_GROUP);
if (input) {
if (input instanceof EditorInput) {
return this.editorService.openEditor(input, entry.getOptions() || undefined, SIDE_GROUP);
}
const resourceInput = input as IResourceInput;
resourceInput.options = mixin(resourceInput.options, entry.getOptions());
return this.editorService.openEditor(resourceInput, SIDE_GROUP);
}
const resourceInput = input as IResourceInput;
resourceInput.options = mixin(resourceInput.options, entry.getOptions());
return this.editorService.openEditor(resourceInput, SIDE_GROUP);
}
return Promise.resolve(false);

View File

@@ -762,13 +762,13 @@ export function getMultiSelectedEditorContexts(editorContext: IEditorCommandsCon
return !!editorContext ? [editorContext] : [];
}
function isEditorGroup(thing: any): thing is IEditorGroup {
function isEditorGroup(thing: unknown): thing is IEditorGroup {
const group = thing as IEditorGroup;
return group && typeof group.id === 'number' && Array.isArray(group.editors);
}
function isEditorIdentifier(thing: any): thing is IEditorIdentifier {
function isEditorIdentifier(thing: unknown): thing is IEditorIdentifier {
const identifier = thing as IEditorIdentifier;
return identifier && typeof identifier.groupId === 'number';

View File

@@ -68,7 +68,7 @@ export class EditorControl extends Disposable {
const control = this.doShowEditorControl(descriptor);
// Set input
return this.doSetInput(control, editor, withUndefinedAsNull(options)).then((editorChanged => (({ control, editorChanged } as IOpenEditorResult))));
return this.doSetInput(control, editor, withUndefinedAsNull(options)).then((editorChanged => (({ control, editorChanged }))));
}
private doShowEditorControl(descriptor: IEditorDescriptor): BaseEditor {

View File

@@ -257,12 +257,16 @@ class DropOverlay extends Themable {
// Check for URI transfer
else {
const dropHandler = this.instantiationService.createInstance(ResourcesDropHandler, { allowWorkspaceOpen: true /* open workspace instead of file if dropped */ });
dropHandler.handleDrop(event, () => ensureTargetGroup(), targetGroup => targetGroup!.focus());
dropHandler.handleDrop(event, () => ensureTargetGroup(), targetGroup => {
if (targetGroup) {
targetGroup.focus();
}
});
}
}
private isCopyOperation(e: DragEvent, draggedEditor?: IEditorIdentifier): boolean {
if (draggedEditor && !(draggedEditor.editor as EditorInput).supportsSplitEditor()) {
if (draggedEditor && draggedEditor.editor instanceof EditorInput && !draggedEditor.editor.supportsSplitEditor()) {
return false;
}

View File

@@ -49,7 +49,7 @@ import { GlobalNewUntitledFileAction } from 'vs/workbench/contrib/files/browser/
import { isErrorWithActions, IErrorWithActions } from 'vs/base/common/errorsWithActions';
import { IVisibleEditor } from 'vs/workbench/services/editor/common/editorService';
import { withNullAsUndefined } from 'vs/base/common/types';
import { IHashService } from 'vs/workbench/services/hash/common/hashService';
import { hash } from 'vs/base/common/hash';
import { guessMimeTypes } from 'vs/base/common/mime';
import { extname } from 'vs/base/common/path';
@@ -132,7 +132,6 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
@IKeybindingService private readonly keybindingService: IKeybindingService,
@IMenuService private readonly menuService: IMenuService,
@IContextMenuService private readonly contextMenuService: IContextMenuService,
@IHashService private readonly hashService: IHashService,
// {{SQL CARBON EDIT}}
@ICommandService private commandService: ICommandService
) {
@@ -224,7 +223,7 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
let activeEditorListener: IDisposable;
const observeActiveEditor = () => {
activeEditorListener = dispose(activeEditorListener);
dispose(activeEditorListener);
const activeEditor = this._group.activeEditor;
if (activeEditor) {
@@ -467,16 +466,14 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
private onDidEditorOpen(editor: EditorInput): void {
// Telemetry
this.toEditorTelemetryDescriptor(editor).then(descriptor => {
/* __GDPR__
"editorOpened" : {
"${include}": [
"${EditorTelemetryDescriptor}"
]
}
*/
this.telemetryService.publicLog('editorOpened', descriptor);
});
/* __GDPR__
"editorOpened" : {
"${include}": [
"${EditorTelemetryDescriptor}"
]
}
*/
this.telemetryService.publicLog('editorOpened', this.toEditorTelemetryDescriptor(editor));
// Update container
this.updateContainer();
@@ -508,16 +505,14 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
});
// Telemetry
this.toEditorTelemetryDescriptor(event.editor).then(descriptor => {
/* __GDPR__
/* __GDPR__
"editorClosed" : {
"${include}": [
"${EditorTelemetryDescriptor}"
]
}
*/
this.telemetryService.publicLog('editorClosed', descriptor);
});
this.telemetryService.publicLog('editorClosed', this.toEditorTelemetryDescriptor(event.editor));
// Update container
this.updateContainer();
@@ -527,24 +522,22 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
this._onDidGroupChange.fire({ kind: GroupChangeKind.EDITOR_CLOSE, editor, editorIndex: event.index });
}
private toEditorTelemetryDescriptor(editor: EditorInput): Thenable<object> {
private toEditorTelemetryDescriptor(editor: EditorInput): object {
const descriptor = editor.getTelemetryDescriptor();
const resource = editor.getResource();
if (resource && resource.fsPath) {
return this.hashService.createSHA1(resource.fsPath).then(hashedPath => {
descriptor['resource'] = { mimeType: guessMimeTypes(resource.fsPath).join(', '), scheme: resource.scheme, ext: extname(resource.fsPath), path: hashedPath };
descriptor['resource'] = { mimeType: guessMimeTypes(resource.fsPath).join(', '), scheme: resource.scheme, ext: extname(resource.fsPath), path: hash(resource.fsPath) };
/* __GDPR__FRAGMENT__
"EditorTelemetryDescriptor" : {
"resource": { "${inline}": [ "${URIDescriptor}" ] }
}
*/
return descriptor;
});
/* __GDPR__FRAGMENT__
"EditorTelemetryDescriptor" : {
"resource": { "${inline}": [ "${URIDescriptor}" ] }
}
*/
return descriptor;
}
return Promise.resolve(descriptor);
return descriptor;
}
private onDidEditorDispose(editor: EditorInput): void {
@@ -1229,10 +1222,10 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
}
// Filter: direction (left / right)
else if (hasDirection) {
else if (hasDirection && filter.except) {
editorsToClose = (filter.direction === CloseDirection.LEFT) ?
editorsToClose.slice(0, this._group.indexOf(filter.except as EditorInput)) :
editorsToClose.slice(this._group.indexOf(filter.except as EditorInput) + 1);
editorsToClose.slice(0, this._group.indexOf(filter.except)) :
editorsToClose.slice(this._group.indexOf(filter.except) + 1);
}
// Filter: except

View File

@@ -844,7 +844,7 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
}
private doCreateGridControlWithPreviousState(): boolean {
const uiState = this.workspaceMemento[EditorPart.EDITOR_PART_UI_STATE_STORAGE_KEY] as IEditorPartUIState;
const uiState: IEditorPartUIState = this.workspaceMemento[EditorPart.EDITOR_PART_UI_STATE_STORAGE_KEY];
if (uiState && uiState.serializedGrid) {
try {

View File

@@ -6,10 +6,10 @@
import 'vs/css!./media/editorstatus';
import * as nls from 'vs/nls';
import { $, append, runAtThisOrScheduleAtNextAnimationFrame } from 'vs/base/browser/dom';
import * as strings from 'vs/base/common/strings';
import { format } from 'vs/base/common/strings';
import { extname, basename } from 'vs/base/common/resources';
import * as types from 'vs/base/common/types';
import { URI as uri } from 'vs/base/common/uri';
import { areFunctions, withNullAsUndefined } from 'vs/base/common/types';
import { URI } from 'vs/base/common/uri';
import { IStatusbarItem } from 'vs/workbench/browser/parts/statusbar/statusbar';
import { Action } from 'vs/base/common/actions';
import { Language } from 'vs/base/common/platform';
@@ -87,7 +87,7 @@ function toEditorWithEncodingSupport(input: IEditorInput): IEncodingSupport | nu
// File or Resource Editor
let encodingSupport = input as IFileEditorInput;
if (types.areFunctions(encodingSupport.setEncoding, encodingSupport.getEncoding)) {
if (areFunctions(encodingSupport.setEncoding, encodingSupport.getEncoding)) {
return encodingSupport;
}
@@ -457,18 +457,18 @@ export class EditorStatus implements IStatusbarItem {
if (info.selections.length === 1) {
if (info.charactersSelected) {
return strings.format(nlsSingleSelectionRange, info.selections[0].positionLineNumber, info.selections[0].positionColumn, info.charactersSelected);
return format(nlsSingleSelectionRange, info.selections[0].positionLineNumber, info.selections[0].positionColumn, info.charactersSelected);
}
return strings.format(nlsSingleSelection, info.selections[0].positionLineNumber, info.selections[0].positionColumn);
return format(nlsSingleSelection, info.selections[0].positionLineNumber, info.selections[0].positionColumn);
}
if (info.charactersSelected) {
return strings.format(nlsMultiSelectionRange, info.selections.length, info.charactersSelected);
return format(nlsMultiSelectionRange, info.selections.length, info.charactersSelected);
}
if (info.selections.length > 0) {
return strings.format(nlsMultiSelection, info.selections.length);
return format(nlsMultiSelection, info.selections.length);
}
return undefined;
@@ -536,7 +536,7 @@ export class EditorStatus implements IStatusbarItem {
private updateStatusBar(): void {
const activeControl = this.editorService.activeControl;
const activeCodeEditor = activeControl ? types.withNullAsUndefined(getCodeEditor(activeControl.getControl())) : undefined;
const activeCodeEditor = activeControl ? withNullAsUndefined(getCodeEditor(activeControl.getControl())) : undefined;
// Update all states
this.onScreenReaderModeChange(activeCodeEditor);
@@ -769,7 +769,7 @@ export class EditorStatus implements IStatusbarItem {
this.updateState(info);
}
private onResourceEncodingChange(resource: uri): void {
private onResourceEncodingChange(resource: URI): void {
const activeControl = this.editorService.activeControl;
if (activeControl) {
const activeResource = toResource(activeControl.input, { supportSideBySide: true });
@@ -876,14 +876,14 @@ export class ChangeModeAction extends Action {
}
// construct a fake resource to be able to show nice icons if any
let fakeResource: uri | undefined;
let fakeResource: URI | undefined;
const extensions = this.modeService.getExtensions(lang);
if (extensions && extensions.length) {
fakeResource = uri.file(extensions[0]);
fakeResource = URI.file(extensions[0]);
} else {
const filenames = this.modeService.getFilenames(lang);
if (filenames && filenames.length) {
fakeResource = uri.file(filenames[0]);
fakeResource = URI.file(filenames[0]);
}
}
@@ -997,7 +997,7 @@ export class ChangeModeAction extends Action {
});
}
private configureFileAssociation(resource: uri): void {
private configureFileAssociation(resource: URI): void {
const extension = extname(resource);
const base = basename(resource);
const currentAssociation = this.modeService.getModeIdByFilepathOrFirstLine(base);
@@ -1208,7 +1208,7 @@ export class ChangeEncodingAction extends Action {
.then((guessedEncoding: string) => {
const isReopenWithEncoding = (action === reopenWithEncodingPick);
const configuredEncoding = this.textResourceConfigurationService.getValue(types.withNullAsUndefined(resource), 'files.encoding');
const configuredEncoding = this.textResourceConfigurationService.getValue(withNullAsUndefined(resource), 'files.encoding');
let directMatchIndex: number | undefined;
let aliasMatchIndex: number | undefined;

View File

@@ -101,7 +101,7 @@ export class OpenWorkspaceButtonContribution extends Disposable implements IEdit
private static readonly ID = 'editor.contrib.openWorkspaceButton';
private openWorkspaceButton: FloatingClickWidget;
private openWorkspaceButton: FloatingClickWidget | undefined;
constructor(
private editor: ICodeEditor,
@@ -163,7 +163,7 @@ export class OpenWorkspaceButtonContribution extends Disposable implements IEdit
this._register(this.openWorkspaceButton.onClick(() => {
const model = this.editor.getModel();
if (model) {
this.windowService.openWindow([{ uri: model.uri, typeHint: 'file' }]);
this.windowService.openWindow([{ fileUri: model.uri }]);
}
}));
@@ -172,7 +172,8 @@ export class OpenWorkspaceButtonContribution extends Disposable implements IEdit
}
private disposeOpenWorkspaceWidgetRenderer(): void {
this.openWorkspaceButton = dispose(this.openWorkspaceButton);
dispose(this.openWorkspaceButton);
this.openWorkspaceButton = undefined;
}
dispose(): void {

View File

@@ -141,12 +141,12 @@ export class SideBySideEditor extends BaseEditor {
this.splitview.layout(dimension.width);
}
getControl(): IEditorControl | null {
getControl(): IEditorControl | undefined {
if (this.masterEditor) {
return this.masterEditor.getControl();
}
return null;
return undefined;
}
getMasterEditor(): IEditor | undefined {

View File

@@ -227,7 +227,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
private isFileBinaryError(error: Error[]): boolean;
private isFileBinaryError(error: Error): boolean;
private isFileBinaryError(error: any): boolean {
private isFileBinaryError(error: Error | Error[]): boolean {
if (types.isArray(error)) {
const errors = <Error[]>error;
return errors.some(e => this.isFileBinaryError(e));
@@ -312,9 +312,9 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
return control.saveViewState();
}
private toDiffEditorViewStateResource(modelOrInput: IDiffEditorModel | DiffEditorInput): URI | null {
let original: URI | null;
let modified: URI | null;
private toDiffEditorViewStateResource(modelOrInput: IDiffEditorModel | DiffEditorInput): URI | undefined {
let original: URI | undefined;
let modified: URI | undefined;
if (modelOrInput instanceof DiffEditorInput) {
original = modelOrInput.originalInput.getResource();
@@ -325,7 +325,7 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
}
if (!original || !modified) {
return null;
return undefined;
}
// create a URI that is the Base64 concatenation of original + modified resource

View File

@@ -19,7 +19,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ITextFileService, SaveReason, AutoSaveMode } from 'vs/workbench/services/textfile/common/textfiles';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
import { IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { isDiffEditor, isCodeEditor, ICodeEditor, getCodeEditor } from 'vs/editor/browser/editorBrowser';
import { isDiffEditor, isCodeEditor, getCodeEditor } from 'vs/editor/browser/editorBrowser';
import { IEditorGroupsService, IEditorGroup } from 'vs/workbench/services/editor/common/editorGroupsService';
import { CancellationToken } from 'vs/base/common/cancellation';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
@@ -241,7 +241,11 @@ export abstract class BaseTextEditor extends BaseEditor implements ITextEditor {
}
protected retrieveTextEditorViewState(resource: URI): IEditorViewState | null {
const control = this.getControl() as ICodeEditor;
const control = this.getControl();
if (!isCodeEditor(control)) {
return null;
}
const model = control.getModel();
if (!model) {
return null; // view state always needs a model
@@ -302,7 +306,7 @@ export abstract class BaseTextEditor extends BaseEditor implements ITextEditor {
}
}
protected getResource(): URI | null {
protected getResource(): URI | undefined {
const codeEditor = getCodeEditor(this.editorControl);
if (codeEditor) {
const model = codeEditor.getModel();
@@ -315,7 +319,7 @@ export abstract class BaseTextEditor extends BaseEditor implements ITextEditor {
return this.input.getResource();
}
return null;
return undefined;
}
protected abstract getAriaLabel(): string;

View File

@@ -8,7 +8,7 @@ import { addDisposableListener, Dimension, EventType } from 'vs/base/browser/dom
import { StandardMouseEvent } from 'vs/base/browser/mouseEvent';
import { ActionsOrientation, IActionItem } from 'vs/base/browser/ui/actionbar/actionbar';
import { ToolBar } from 'vs/base/browser/ui/toolbar/toolbar';
import { Action, IAction, IRunEvent } from 'vs/base/common/actions';
import { IAction, IRunEvent } from 'vs/base/common/actions';
import * as arrays from 'vs/base/common/arrays';
import { ResolvedKeybinding } from 'vs/base/common/keyCodes';
import { dispose, IDisposable } from 'vs/base/common/lifecycle';
@@ -123,10 +123,10 @@ export abstract class TitleControl extends Themable {
protected abstract handleBreadcrumbsEnablementChange(): void;
protected createEditorActionsToolBar(container: HTMLElement): void {
const context = { groupId: this.group.id } as IEditorCommandsContext;
const context: IEditorCommandsContext = { groupId: this.group.id };
this.editorActionsToolbar = this._register(new ToolBar(container, this.contextMenuService, {
actionItemProvider: action => this.actionItemProvider(action as Action),
actionItemProvider: action => this.actionItemProvider(action),
orientation: ActionsOrientation.HORIZONTAL,
ariaLabel: localize('araLabelEditorActions', "Editor actions"),
getKeyBinding: action => this.getKeybinding(action),
@@ -156,7 +156,7 @@ export abstract class TitleControl extends Themable {
}));
}
private actionItemProvider(action: Action): IActionItem | undefined {
private actionItemProvider(action: IAction): IActionItem | undefined {
const activeControl = this.group.activeControl;
// Check Active Editor
@@ -303,7 +303,7 @@ export abstract class TitleControl extends Themable {
this.contextMenuService.showContextMenu({
getAnchor: () => anchor,
getActions: () => actions,
getActionsContext: () => ({ groupId: this.group.id, editorIndex: this.group.getIndexOfEditor(editor) } as IEditorCommandsContext),
getActionsContext: () => ({ groupId: this.group.id, editorIndex: this.group.getIndexOfEditor(editor) }),
getKeyBinding: (action) => this.getKeybinding(action),
onHide: () => {