Merge from vscode 05fc61ffb1aee9fd19173c32113daed079f9b7bd (#5074)

* Merge from vscode 05fc61ffb1aee9fd19173c32113daed079f9b7bd

* fix tests
This commit is contained in:
Anthony Dresser
2019-04-16 22:11:30 -07:00
committed by GitHub
parent 2f8519cb6b
commit 8956b591f7
217 changed files with 5120 additions and 3926 deletions

View File

@@ -19,7 +19,7 @@ import { RemoteAuthorityResolverService } from 'vs/platform/remote/browser/remot
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IFileService } from 'vs/platform/files/common/files';
import { FileService3 } from 'vs/workbench/services/files2/browser/fileService2';
import { FileService } from 'vs/workbench/services/files/common/fileService';
import { Schemas } from 'vs/base/common/network';
class CodeRendererMain extends Disposable {
@@ -78,7 +78,7 @@ class CodeRendererMain extends Disposable {
serviceCollection.set(IRemoteAgentService, remoteAgentService);
// Files
const fileService = this._register(new FileService3(logService));
const fileService = this._register(new FileService(logService));
serviceCollection.set(IFileService, fileService);
const connection = remoteAgentService.getConnection();

View File

@@ -5,8 +5,7 @@
import { URI } from 'vs/base/common/uri';
import { IBackupFileService } from 'vs/workbench/services/backup/common/backup';
import { ITextSnapshot } from 'vs/platform/files/common/files';
import { ITextBufferFactory } from 'vs/editor/common/model';
import { ITextBufferFactory, ITextSnapshot } from 'vs/editor/common/model';
import { createTextBufferFactoryFromSnapshot } from 'vs/editor/common/model/textModel';
import { keys, ResourceMap } from 'vs/base/common/map';
import { registerSingleton } from 'vs/platform/instantiation/common/extensions';
@@ -52,7 +51,7 @@ import { ExportData } from 'vs/base/common/performance';
import { IRecentlyOpened, IRecent } from 'vs/platform/history/common/history';
import { ISerializableCommandAction } from 'vs/platform/actions/common/actions';
import { IWorkspaceEditingService } from 'vs/workbench/services/workspace/common/workspaceEditing';
import { IWorkspaceContextService, Workspace, toWorkspaceFolders, IWorkspaceFolder, WorkbenchState, IWorkspace } from 'vs/platform/workspace/common/workspace';
import { IWorkspaceContextService, Workspace, toWorkspaceFolder, IWorkspaceFolder, WorkbenchState, IWorkspace } from 'vs/platform/workspace/common/workspace';
import { ITextResourcePropertiesService } from 'vs/editor/common/services/resourceConfiguration';
import { IKeybindingService } from 'vs/platform/keybinding/common/keybinding';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
@@ -1366,10 +1365,7 @@ export class SimpleWorkspaceService implements IWorkspaceContextService {
readonly onDidChangeWorkbenchState = Event.None;
constructor() {
this.workspace = new Workspace(
workspaceResource.toString(),
toWorkspaceFolders([{ uri: workspaceResource.toString() }])
);
this.workspace = new Workspace(workspaceResource.toString(), [toWorkspaceFolder(workspaceResource)]);
}
getFolders(): IWorkspaceFolder[] {

View File

@@ -15,7 +15,7 @@ import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ResourceViewerContext, ResourceViewer } from 'vs/workbench/browser/parts/editor/resourceViewer';
import { URI } from 'vs/base/common/uri';
import { Dimension, size, clearNode } from 'vs/base/browser/dom';
import { IFileService } from 'vs/platform/files/common/files';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { CancellationToken } from 'vs/base/common/cancellation';
import { dispose } from 'vs/base/common/lifecycle';
import { IStorageService } from 'vs/platform/storage/common/storage';
@@ -47,7 +47,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
callbacks: IOpenCallbacks,
telemetryService: ITelemetryService,
themeService: IThemeService,
@IFileService private readonly _fileService: IFileService,
@ITextFileService private readonly textFileService: ITextFileService,
@IStorageService storageService: IStorageService
) {
super(id, telemetryService, themeService, storageService);
@@ -89,7 +89,7 @@ export abstract class BaseBinaryResourceEditor extends BaseEditor {
// Render Input
this.resourceViewerContext = ResourceViewer.show(
{ name: model.getName(), resource: model.getResource(), size: model.getSize(), etag: model.getETag(), mime: model.getMime() },
this._fileService,
this.textFileService,
this.binaryContainer,
this.scrollbar,
resource => this.handleOpenInternalCallback(input, options),

View File

@@ -26,7 +26,7 @@ import { BaseBinaryResourceEditor } from 'vs/workbench/browser/parts/editor/bina
import { BinaryResourceDiffEditor } from 'vs/workbench/browser/parts/editor/binaryDiffEditor';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { IQuickOpenService } from 'vs/platform/quickOpen/common/quickOpen';
import { SUPPORTED_ENCODINGS, IFileService, FILES_ASSOCIATIONS_CONFIG } from 'vs/platform/files/common/files';
import { IFileService, FILES_ASSOCIATIONS_CONFIG } from 'vs/platform/files/common/files';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IModeService, ILanguageSelection } from 'vs/editor/common/services/modeService';
import { IModelService } from 'vs/editor/common/services/modelService';
@@ -35,7 +35,7 @@ import { Selection } from 'vs/editor/common/core/selection';
import { TabFocus } from 'vs/editor/common/config/commonEditorConfig';
import { ICommandService } from 'vs/platform/commands/common/commands';
import { IExtensionGalleryService } from 'vs/platform/extensionManagement/common/extensionManagement';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { ITextFileService, SUPPORTED_ENCODINGS } from 'vs/workbench/services/textfile/common/textfiles';
import { ICursorPositionChangedEvent } from 'vs/editor/common/controller/cursorEvents';
import { IConfigurationChangedEvent, IEditorOptions } from 'vs/editor/common/config/editorOptions';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
@@ -1152,7 +1152,8 @@ export class ChangeEncodingAction extends Action {
@IEditorService private readonly editorService: IEditorService,
@IQuickInputService private readonly quickInputService: IQuickInputService,
@ITextResourceConfigurationService private readonly textResourceConfigurationService: ITextResourceConfigurationService,
@IFileService private readonly fileService: IFileService
@IFileService private readonly fileService: IFileService,
@ITextFileService private readonly textFileService: ITextFileService
) {
super(actionId, actionLabel);
}
@@ -1203,7 +1204,7 @@ export class ChangeEncodingAction extends Action {
return Promise.resolve(null); // encoding detection only possible for resources the file service can handle
}
return this.fileService.resolveContent(resource, { autoGuessEncoding: true, acceptTextOnly: true }).then(content => content.encoding, err => null);
return this.textFileService.read(resource, { autoGuessEncoding: true, acceptTextOnly: true }).then(content => content.encoding, err => null);
})
.then((guessedEncoding: string) => {
const isReopenWithEncoding = (action === reopenWithEncodingPick);

View File

@@ -145,8 +145,13 @@ export class NoTabsTitleControl extends TitleControl {
this.redraw();
}
updateEditorLabel(editor: IEditorInput): void {
this.ifEditorIsActive(editor, () => this.redraw());
updateEditorLabel(editor?: IEditorInput): void {
if (!editor) {
editor = withNullAsUndefined(this.group.activeEditor);
}
if (editor) {
this.ifEditorIsActive(editor, () => this.redraw());
}
}
updateEditorDirty(editor: IEditorInput): void {

View File

@@ -21,7 +21,7 @@ import { Action } from 'vs/base/common/actions';
import { IEditorService } from 'vs/workbench/services/editor/common/editorService';
import { memoize } from 'vs/base/common/decorators';
import * as platform from 'vs/base/common/platform';
import { IFileService } from 'vs/platform/files/common/files';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
export interface IResourceDescriptor {
readonly resource: URI;
@@ -72,7 +72,7 @@ export class ResourceViewer {
static show(
descriptor: IResourceDescriptor,
fileService: IFileService,
textFileService: ITextFileService,
container: HTMLElement,
scrollbar: DomScrollableElement,
openInternalClb: (uri: URI) => void,
@@ -85,7 +85,7 @@ export class ResourceViewer {
// Images
if (ResourceViewer.isImageResource(descriptor)) {
return ImageView.create(container, descriptor, fileService, scrollbar, openExternalClb, metadataClb);
return ImageView.create(container, descriptor, textFileService, scrollbar, openExternalClb, metadataClb);
}
// Large Files
@@ -114,13 +114,13 @@ class ImageView {
static create(
container: HTMLElement,
descriptor: IResourceDescriptor,
fileService: IFileService,
textFileService: ITextFileService,
scrollbar: DomScrollableElement,
openExternalClb: (uri: URI) => void,
metadataClb: (meta: string) => void
): ResourceViewerContext {
if (ImageView.shouldShowImageInline(descriptor)) {
return InlineImageView.create(container, descriptor, fileService, scrollbar, metadataClb);
return InlineImageView.create(container, descriptor, textFileService, scrollbar, metadataClb);
}
return LargeImageView.create(container, descriptor, openExternalClb, metadataClb);
@@ -357,7 +357,7 @@ class InlineImageView {
static create(
container: HTMLElement,
descriptor: IResourceDescriptor,
fileService: IFileService,
textFileService: ITextFileService,
scrollbar: DomScrollableElement,
metadataClb: (meta: string) => void
) {
@@ -559,7 +559,7 @@ class InlineImageView {
}
}));
InlineImageView.imageSrc(descriptor, fileService).then(dataUri => {
InlineImageView.imageSrc(descriptor, textFileService).then(dataUri => {
const imgs = container.getElementsByTagName('img');
if (imgs.length) {
imgs[0].src = dataUri;
@@ -569,12 +569,12 @@ class InlineImageView {
return context;
}
private static imageSrc(descriptor: IResourceDescriptor, fileService: IFileService): Promise<string> {
private static imageSrc(descriptor: IResourceDescriptor, textFileService: ITextFileService): Promise<string> {
if (descriptor.resource.scheme === Schemas.data) {
return Promise.resolve(descriptor.resource.toString(true /* skip encoding */));
}
return fileService.resolveContent(descriptor.resource, { encoding: 'base64' }).then(data => {
return textFileService.read(descriptor.resource, { encoding: 'base64' }).then(data => {
const mime = getMime(descriptor);
return `data:${mime};base64,${data.value}`;

View File

@@ -42,6 +42,7 @@ import { IConfigurationService } from 'vs/platform/configuration/common/configur
import { BreadcrumbsControl } from 'vs/workbench/browser/parts/editor/breadcrumbsControl';
import { IFileService } from 'vs/platform/files/common/files';
import { withNullAsUndefined } from 'vs/base/common/types';
import { ILabelService } from 'vs/platform/label/common/label';
// {{SQL CARBON EDIT}} -- Display the editor's tab color
import { ICommandService } from 'vs/platform/commands/common/commands';
@@ -94,8 +95,9 @@ export class TabsTitleControl extends TitleControl {
// {{SQL CARBON EDIT}} -- Display the editor's tab color
@ICommandService private commandService: ICommandService,
// {{SQL CARBON EDIT}} -- End
@ILabelService labelService: ILabelService
) {
super(parent, accessor, group, contextMenuService, instantiationService, contextKeyService, keybindingService, telemetryService, notificationService, menuService, quickOpenService, themeService, extensionService, configurationService, fileService);
super(parent, accessor, group, contextMenuService, instantiationService, contextKeyService, keybindingService, telemetryService, notificationService, menuService, quickOpenService, themeService, extensionService, configurationService, fileService, labelService);
}
protected create(parent: HTMLElement): void {

View File

@@ -15,13 +15,12 @@ import { DiffEditorInput } from 'vs/workbench/common/editor/diffEditorInput';
import { DiffNavigator } from 'vs/editor/browser/widget/diffNavigator';
import { DiffEditorWidget } from 'vs/editor/browser/widget/diffEditorWidget';
import { TextDiffEditorModel } from 'vs/workbench/common/editor/textDiffEditorModel';
import { FileOperationError, FileOperationResult } from 'vs/platform/files/common/files';
import { ITelemetryService } from 'vs/platform/telemetry/common/telemetry';
import { IStorageService } from 'vs/platform/storage/common/storage';
import { ITextResourceConfigurationService } from 'vs/editor/common/services/resourceConfiguration';
import { IInstantiationService } from 'vs/platform/instantiation/common/instantiation';
import { IThemeService } from 'vs/platform/theme/common/themeService';
import { ITextFileService } from 'vs/workbench/services/textfile/common/textfiles';
import { ITextFileService, TextFileOperationError, TextFileOperationResult } from 'vs/workbench/services/textfile/common/textfiles';
import { ScrollType, IDiffEditorViewState, IDiffEditorModel } from 'vs/editor/common/editorCommon';
import { IDisposable, dispose } from 'vs/base/common/lifecycle';
import { Registry } from 'vs/platform/registry/common/platform';
@@ -242,10 +241,11 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
private isFileBinaryError(error: Error | Error[]): boolean {
if (types.isArray(error)) {
const errors = <Error[]>error;
return errors.some(e => this.isFileBinaryError(e));
}
return (<FileOperationError>error).fileOperationResult === FileOperationResult.FILE_IS_BINARY;
return (<TextFileOperationError>error).textFileOperationResult === TextFileOperationResult.FILE_IS_BINARY;
}
clearInput(): void {

View File

@@ -40,6 +40,7 @@ import { IExtensionService } from 'vs/workbench/services/extensions/common/exten
import { AnchorAlignment } from 'vs/base/browser/ui/contextview/contextview';
import { IFileService } from 'vs/platform/files/common/files';
import { withNullAsUndefined } from 'vs/base/common/types';
import { ILabelService } from 'vs/platform/label/common/label';
export interface IToolbarActions {
primary: IAction[];
@@ -79,6 +80,7 @@ export abstract class TitleControl extends Themable {
@IExtensionService private readonly extensionService: IExtensionService,
@IConfigurationService protected configurationService: IConfigurationService,
@IFileService private readonly fileService: IFileService,
@ILabelService private readonly labelService: ILabelService
) {
super(themeService);
@@ -91,6 +93,7 @@ export abstract class TitleControl extends Themable {
private registerListeners(): void {
this._register(this.extensionService.onDidRegisterExtensions(() => this.updateEditorActionsToolbar()));
this._register(this.labelService.onDidChangeFormatters(() => this.updateEditorLabel()));
}
protected abstract create(parent: HTMLElement): void;
@@ -340,7 +343,7 @@ export abstract class TitleControl extends Themable {
abstract setActive(isActive: boolean): void;
abstract updateEditorLabel(editor: IEditorInput): void;
abstract updateEditorLabel(editor?: IEditorInput): void;
abstract updateEditorDirty(editor: IEditorInput): void;

View File

@@ -50,6 +50,13 @@
padding: 6px 6px 4px 6px;
}
.quick-input-and-message {
display: flex;
flex-direction: column;
flex-grow: 1;
position: relative;
}
.quick-input-check-all {
align-self: center;
margin: 0;
@@ -65,7 +72,8 @@
flex-grow: 1;
}
.quick-input-widget.show-checkboxes .quick-input-box {
.quick-input-widget.show-checkboxes .quick-input-box,
.quick-input-widget.show-checkboxes .quick-input-message {
margin-left: 5px;
}
@@ -95,7 +103,8 @@
}
.quick-input-message {
margin: 0px 11px;
margin-top: -1px;
padding: 6px 5px 2px 5px;
}
.quick-input-progress.monaco-progress-container {

View File

@@ -301,6 +301,18 @@ class QuickInput implements IQuickInput {
return '';
}
protected showMessageDecoration(severity: Severity) {
this.ui.inputBox.showDecoration(severity);
if (severity === Severity.Error) {
const styles = this.ui.inputBox.stylesForType(severity);
this.ui.message.style.backgroundColor = styles.background ? `${styles.background}` : null;
this.ui.message.style.border = styles.border ? `1px solid ${styles.border}` : null;
} else {
this.ui.message.style.backgroundColor = '';
this.ui.message.style.border = '';
}
}
public dispose(): void {
this.hide();
this.disposables = dispose(this.disposables);
@@ -742,10 +754,10 @@ class QuickPick<T extends IQuickPickItem> extends QuickInput implements IQuickPi
}
if (this.validationMessage) {
this.ui.message.textContent = this.validationMessage;
this.ui.inputBox.showDecoration(Severity.Error);
this.showMessageDecoration(Severity.Error);
} else {
this.ui.message.textContent = null;
this.ui.inputBox.showDecoration(Severity.Ignore);
this.showMessageDecoration(Severity.Info);
}
this.ui.customButton.label = this.customLabel;
this.ui.customButton.element.title = this.customHover;
@@ -876,11 +888,11 @@ class InputBox extends QuickInput implements IInputBox {
}
if (!this.validationMessage && this.ui.message.textContent !== this.noValidationMessage) {
this.ui.message.textContent = this.noValidationMessage;
this.ui.inputBox.showDecoration(Severity.Ignore);
this.showMessageDecoration(Severity.Info);
}
if (this.validationMessage && this.ui.message.textContent !== this.validationMessage) {
this.ui.message.textContent = this.validationMessage;
this.ui.inputBox.showDecoration(Severity.Error);
this.showMessageDecoration(Severity.Error);
}
this.ui.setVisibilities({ title: !!this.title || !!this.step, inputBox: true, message: true });
}
@@ -1044,7 +1056,8 @@ export class QuickInputService extends Component implements IQuickInputService {
}
}));
this.filterContainer = dom.append(headerContainer, $('.quick-input-filter'));
const extraContainer = dom.append(headerContainer, $('.quick-input-and-message'));
this.filterContainer = dom.append(extraContainer, $('.quick-input-filter'));
const inputBox = this._register(new QuickInputBox(this.filterContainer));
inputBox.setAttribute('aria-describedby', `${this.idPrefix}message`);
@@ -1075,7 +1088,7 @@ export class QuickInputService extends Component implements IQuickInputService {
this.onDidCustomEmitter.fire();
}));
const message = dom.append(container, $(`#${this.idPrefix}message.quick-input-message`));
const message = dom.append(extraContainer, $(`#${this.idPrefix}message.quick-input-message`));
const progressBar = new ProgressBar(container);
dom.addClass(progressBar.getContainer(), 'quick-input-progress');

View File

@@ -101,6 +101,10 @@ export class QuickInputBox {
}
}
stylesForType(decoration: Severity) {
return this.inputBox.stylesForType(decoration === Severity.Info ? MessageType.INFO : decoration === Severity.Warning ? MessageType.WARNING : MessageType.ERROR);
}
setFocus(): void {
this.inputBox.focus();
}

View File

@@ -23,7 +23,6 @@ import { Position, Parts, IWorkbenchLayoutService } from 'vs/workbench/services/
import { IStorageService } from 'vs/platform/storage/common/storage';
import { IConfigurationService } from 'vs/platform/configuration/common/configuration';
import { IViewletService } from 'vs/workbench/services/viewlet/browser/viewlet';
import { IFileService, ILegacyFileService } from 'vs/platform/files/common/files';
import { IPanelService } from 'vs/workbench/services/panel/common/panelService';
import { IInstantiationService, ServicesAccessor } from 'vs/platform/instantiation/common/instantiation';
import { ServiceCollection } from 'vs/platform/instantiation/common/serviceCollection';
@@ -197,20 +196,12 @@ export class Workbench extends Layout {
instantiationService.invokeFunction(accessor => {
const lifecycleService = accessor.get(ILifecycleService);
// TODO@Ben legacy file service
const fileService = accessor.get(IFileService) as any;
if (typeof fileService.setLegacyService === 'function') {
try {
fileService.setLegacyService(accessor.get(ILegacyFileService));
} catch (error) {
//ignore, legacy file service might not be registered
}
}
// TODO@Sandeep debt around cyclic dependencies
const configurationService = accessor.get(IConfigurationService) as any;
if (typeof configurationService.acquireInstantiationService === 'function') {
configurationService.acquireInstantiationService(instantiationService);
setTimeout(() => {
configurationService.acquireInstantiationService(instantiationService);
}, 0);
}
// Signal to lifecycle that services are set