Merge from vscode 91e99652cd5fcfc072387c64e151b435e39e8dcf (#6962)

This commit is contained in:
Anthony Dresser
2019-08-26 15:58:42 -07:00
committed by GitHub
parent edf470c8fa
commit 507bae90b7
103 changed files with 1743 additions and 1543 deletions

View File

@@ -1239,7 +1239,8 @@ export abstract class Layout extends Disposable implements IWorkbenchLayoutServi
const editorNode: ISerializedLeafNode = {
type: 'leaf',
data: { type: Parts.EDITOR_PART },
size: this.state.panel.position === Position.BOTTOM ? middleSectionHeight - (this.state.panel.hidden ? 0 : panelSize) : editorSectionWidth - (this.state.panel.hidden ? 0 : panelSize)
size: this.state.panel.position === Position.BOTTOM ? middleSectionHeight - (this.state.panel.hidden ? 0 : panelSize) : editorSectionWidth - (this.state.panel.hidden ? 0 : panelSize),
visible: true
};
const panelNode: ISerializedLeafNode = {

View File

@@ -447,7 +447,7 @@ MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: editorCo
MenuRegistry.appendMenuItem(MenuId.EditorTitleContext, { command: { id: editorCommands.SPLIT_EDITOR_RIGHT, title: nls.localize('splitRight', "Split Right") }, group: '5_split', order: 40 });
// Editor Title Menu
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: editorCommands.TOGGLE_DIFF_SIDE_BY_SIDE, title: nls.localize('toggleSideBySideView', "Toggle Side By Side View") }, group: '1_diff', order: 10, when: ContextKeyExpr.has('isInDiffEditor') });
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: editorCommands.TOGGLE_DIFF_SIDE_BY_SIDE, title: nls.localize('toggleInlineView', "Toggle Inline View") }, group: '1_diff', order: 10, when: ContextKeyExpr.has('isInDiffEditor') });
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: editorCommands.SHOW_EDITORS_IN_GROUP, title: nls.localize('showOpenedEditors', "Show Opened Editors") }, group: '3_open', order: 10, when: ContextKeyExpr.has('config.workbench.editor.showTabs') });
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: editorCommands.CLOSE_EDITORS_IN_GROUP_COMMAND_ID, title: nls.localize('closeAll', "Close All") }, group: '5_close', order: 10, when: ContextKeyExpr.has('config.workbench.editor.showTabs') });
MenuRegistry.appendMenuItem(MenuId.EditorTitle, { command: { id: editorCommands.CLOSE_SAVED_EDITORS_COMMAND_ID, title: nls.localize('closeAllSaved', "Close Saved") }, group: '5_close', order: 20, when: ContextKeyExpr.has('config.workbench.editor.showTabs') });

View File

@@ -94,6 +94,7 @@ export interface IEditorGroupsAccessor {
getGroups(order: GroupsOrder): IEditorGroupView[];
activateGroup(identifier: IEditorGroupView | GroupIdentifier): IEditorGroupView;
restoreGroup(identifier: IEditorGroupView | GroupIdentifier): IEditorGroupView;
addGroup(location: IEditorGroupView | GroupIdentifier, direction: GroupDirection, options?: IAddGroupOptions): IEditorGroupView;
mergeGroup(group: IEditorGroupView | GroupIdentifier, target: IEditorGroupView | GroupIdentifier, options?: IMergeGroupOptions): IEditorGroupView;

View File

@@ -618,12 +618,24 @@ export abstract class BaseCloseAllAction extends Action {
async run(): Promise<any> {
// Just close all if there are no or one dirty editor
if (this.textFileService.getDirty().length < 2) {
// Just close all if there are no dirty editors
if (!this.textFileService.isDirty()) {
return this.doCloseAll();
}
// Otherwise ask for combined confirmation
// Otherwise ask for combined confirmation and make sure
// to bring each dirty editor to the front so that the user
// can review if the files should be changed or not.
await Promise.all(this.groupsToClose.map(async groupToClose => {
for (const editor of groupToClose.getEditors(EditorsOrder.MOST_RECENTLY_ACTIVE)) {
if (editor.isDirty()) {
return groupToClose.openEditor(editor);
}
}
return undefined;
}));
const confirm = await this.textFileService.confirmSave();
if (confirm === ConfirmResult.CANCEL) {
return;

View File

@@ -112,7 +112,7 @@ export class EditorControl extends Disposable {
if (!control.getContainer()) {
const controlInstanceContainer = document.createElement('div');
addClass(controlInstanceContainer, 'editor-instance');
controlInstanceContainer.id = descriptor.getId();
controlInstanceContainer.setAttribute('data-editor-id', descriptor.getId());
control.create(controlInstanceContainer);
}

View File

@@ -53,6 +53,7 @@ import { hash } from 'vs/base/common/hash';
import { guessMimeTypes } from 'vs/base/common/mime';
import { extname } from 'vs/base/common/resources';
import { Schemas } from 'vs/base/common/network';
import { EditorActivation } from 'vs/platform/editor/common/editor';
export class EditorGroupView extends Themable implements IEditorGroupView {
@@ -489,7 +490,6 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
private onDidEditorOpen(editor: EditorInput): void {
// Telemetry
/* __GDPR__
"editorOpened" : {
"${include}": [
@@ -528,14 +528,13 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
}
});
// Telemetry
/* __GDPR__
"editorClosed" : {
"${include}": [
"${EditorTelemetryDescriptor}"
]
}
*/
"editorClosed" : {
"${include}": [
"${EditorTelemetryDescriptor}"
]
}
*/
this.telemetryService.publicLog('editorClosed', this.toEditorTelemetryDescriptor(event.editor));
// Update container
@@ -841,12 +840,31 @@ export class EditorGroupView extends Themable implements IEditorGroupView {
openEditorOptions.active = true;
}
// Set group active unless we open inactive or preserve focus
let activateGroup = false;
let restoreGroup = false;
if (options && options.activation === EditorActivation.ACTIVATE) {
// Respect option to force activate an editor group.
activateGroup = true;
} else if (options && options.activation === EditorActivation.PRESERVE) {
// Respect option to preserve active editor group.
activateGroup = false;
} else if (openEditorOptions.active) {
// Finally, we only activate/restore an editor which is
// opening as active editor.
// If preserveFocus is enabled, we only restore but never
// activate the group.
activateGroup = !options || !options.preserveFocus;
restoreGroup = !activateGroup;
}
// Do this before we open the editor in the group to prevent a false
// active editor change event before the editor is loaded
// (see https://github.com/Microsoft/vscode/issues/51679)
if (openEditorOptions.active && (!options || !options.preserveFocus)) {
if (activateGroup) {
this.accessor.activateGroup(this);
} else if (restoreGroup) {
this.accessor.restoreGroup(this);
}
// Actually move the editor if a specific index is provided and we figure

View File

@@ -325,6 +325,13 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
return groupView;
}
restoreGroup(group: IEditorGroupView | GroupIdentifier): IEditorGroupView {
const groupView = this.assertGroupView(group);
this.doRestoreGroup(groupView);
return groupView;
}
getSize(group: IEditorGroupView | GroupIdentifier): { width: number, height: number } {
const groupView = this.assertGroupView(group);
@@ -337,7 +344,7 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
this.gridWidget.resizeView(groupView, size);
}
arrangeGroups(arrangement: GroupsArrangement): void {
arrangeGroups(arrangement: GroupsArrangement, target = this.activeGroup): void {
if (this.count < 2) {
return; // require at least 2 groups to show
}
@@ -351,10 +358,10 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
this.gridWidget.distributeViewSizes();
break;
case GroupsArrangement.MINIMIZE_OTHERS:
this.gridWidget.maximizeViewSize(this.activeGroup);
this.gridWidget.maximizeViewSize(target);
break;
case GroupsArrangement.TOGGLE:
if (this.isGroupMaximized(this.activeGroup)) {
if (this.isGroupMaximized(target)) {
this.arrangeGroups(GroupsArrangement.EVEN);
} else {
this.arrangeGroups(GroupsArrangement.MINIMIZE_OTHERS);
@@ -576,17 +583,21 @@ export class EditorPart extends Part implements IEditorGroupsService, IEditorGro
group.setActive(true);
// Maximize the group if it is currently minimized
if (this.gridWidget) {
const viewSize = this.gridWidget.getViewSize(group);
if (viewSize.width === group.minimumWidth || viewSize.height === group.minimumHeight) {
this.arrangeGroups(GroupsArrangement.MINIMIZE_OTHERS);
}
}
this.doRestoreGroup(group);
// Event
this._onDidActiveGroupChange.fire(group);
}
private doRestoreGroup(group: IEditorGroupView): void {
if (this.gridWidget) {
const viewSize = this.gridWidget.getViewSize(group);
if (viewSize.width === group.minimumWidth || viewSize.height === group.minimumHeight) {
this.arrangeGroups(GroupsArrangement.MINIMIZE_OTHERS, group);
}
}
}
private doUpdateMostRecentActive(group: IEditorGroupView, makeMostRecentlyActive?: boolean): void {
const index = this.mostRecentActiveGroups.indexOf(group.id);

View File

@@ -31,6 +31,7 @@ import { IEditorService } from 'vs/workbench/services/editor/common/editorServic
import { CancellationToken } from 'vs/base/common/cancellation';
import { EditorMemento } from 'vs/workbench/browser/parts/editor/baseEditor';
import { IWindowService } from 'vs/platform/windows/common/windows';
import { EditorActivation } from 'vs/platform/editor/common/editor';
/**
* The text editor that leverages the diff text editor for the editing experience.
@@ -184,6 +185,12 @@ export class TextDiffEditor extends BaseTextEditor implements ITextDiffEditor {
modifiedInput.setForceOpenAsBinary();
}
// Make sure to not steal away the currently active group
// because we are triggering another openEditor() call
// and do not control the initial intent that resulted
// in us now opening as binary.
options.overwrite({ activation: EditorActivation.PRESERVE });
this.editorService.openEditor(binaryDiffInput, options, this.group);
return true;

View File

@@ -18,7 +18,7 @@ import { RemoteAgentService } from 'vs/workbench/services/remote/browser/remoteA
import { RemoteAuthorityResolverService } from 'vs/platform/remote/browser/remoteAuthorityResolverService';
import { IRemoteAuthorityResolverService } from 'vs/platform/remote/common/remoteAuthorityResolver';
import { IRemoteAgentService } from 'vs/workbench/services/remote/common/remoteAgentService';
import { IFileService, IFileSystemProvider } from 'vs/platform/files/common/files';
import { IFileService } from 'vs/platform/files/common/files';
import { FileService } from 'vs/platform/files/common/fileService';
import { Schemas } from 'vs/base/common/network';
import { IWorkspaceContextService } from 'vs/platform/workspace/common/workspace';
@@ -124,7 +124,7 @@ class CodeRendererMain extends Disposable {
const logService = new BufferLogService();
serviceCollection.set(ILogService, logService);
const payload = await this.resolveWorkspaceInitializationPayload();
const payload = this.resolveWorkspaceInitializationPayload();
// Environment
const environmentService = new BrowserWorkbenchEnvironmentService({ workspaceId: payload.id, logsPath, ...this.configuration });
@@ -149,46 +149,7 @@ class CodeRendererMain extends Disposable {
// Files
const fileService = this._register(new FileService(logService));
serviceCollection.set(IFileService, fileService);
// Logger
const indexedDBLogProvider = new IndexedDBLogProvider(logsPath.scheme);
(async () => {
try {
await indexedDBLogProvider.database;
fileService.registerProvider(logsPath.scheme, indexedDBLogProvider);
} catch (error) {
(<ILogService>logService).info('Error while creating indexedDB log provider. Falling back to in-memory log provider.');
(<ILogService>logService).error(error);
fileService.registerProvider(logsPath.scheme, new InMemoryLogProvider(logsPath.scheme));
}
const consoleLogService = new ConsoleLogService(logService.getLevel());
const fileLogService = new FileLogService('window', environmentService.logFile, logService.getLevel(), fileService);
logService.logger = new MultiplexLogService([consoleLogService, fileLogService]);
})();
// User Data Provider
let userDataProvider: IFileSystemProvider | undefined = this.configuration.userDataProvider;
const connection = remoteAgentService.getConnection();
if (connection) {
const channel = connection.getChannel<IChannel>(REMOTE_FILE_SYSTEM_CHANNEL_NAME);
const remoteFileSystemProvider = this._register(new RemoteExtensionsFileSystemProvider(channel, remoteAgentService.getEnvironment()));
fileService.registerProvider(Schemas.vscodeRemote, remoteFileSystemProvider);
if (!userDataProvider) {
const remoteUserDataUri = this.getRemoteUserDataUri();
if (remoteUserDataUri) {
userDataProvider = this._register(new FileUserDataProvider(remoteUserDataUri, joinPath(remoteUserDataUri, BACKUPS), remoteFileSystemProvider, environmentService));
}
}
}
if (!userDataProvider) {
userDataProvider = this._register(new InMemoryUserDataProvider());
}
fileService.registerProvider(Schemas.userData, userDataProvider);
this.registerFileSystemProviders(environmentService, fileService, remoteAgentService, logService, logsPath);
// Long running services (workspace, config, storage)
const services = await Promise.all([
@@ -215,15 +176,59 @@ class CodeRendererMain extends Disposable {
return { serviceCollection, logService, storageService: services[1] };
}
private registerFileSystemProviders(environmentService: IWorkbenchEnvironmentService, fileService: IFileService, remoteAgentService: IRemoteAgentService, logService: BufferLogService, logsPath: URI): void {
// Logger
const indexedDBLogProvider = new IndexedDBLogProvider(logsPath.scheme);
(async () => {
try {
await indexedDBLogProvider.database;
fileService.registerProvider(logsPath.scheme, indexedDBLogProvider);
} catch (error) {
(<ILogService>logService).info('Error while creating indexedDB log provider. Falling back to in-memory log provider.');
(<ILogService>logService).error(error);
fileService.registerProvider(logsPath.scheme, new InMemoryLogProvider(logsPath.scheme));
}
const consoleLogService = new ConsoleLogService(logService.getLevel());
const fileLogService = new FileLogService('window', environmentService.logFile, logService.getLevel(), fileService);
logService.logger = new MultiplexLogService([consoleLogService, fileLogService]);
})();
const connection = remoteAgentService.getConnection();
if (connection) {
// Remote file system
const channel = connection.getChannel<IChannel>(REMOTE_FILE_SYSTEM_CHANNEL_NAME);
const remoteFileSystemProvider = this._register(new RemoteExtensionsFileSystemProvider(channel, remoteAgentService.getEnvironment()));
fileService.registerProvider(Schemas.vscodeRemote, remoteFileSystemProvider);
if (!this.configuration.userDataProvider) {
const remoteUserDataUri = this.getRemoteUserDataUri();
if (remoteUserDataUri) {
this.configuration.userDataProvider = this._register(new FileUserDataProvider(remoteUserDataUri, joinPath(remoteUserDataUri, BACKUPS), remoteFileSystemProvider, environmentService));
}
}
}
// User data
if (!this.configuration.userDataProvider) {
this.configuration.userDataProvider = this._register(new InMemoryUserDataProvider());
}
fileService.registerProvider(Schemas.userData, this.configuration.userDataProvider);
}
private createProductService(): IProductService {
const element = document.getElementById('vscode-remote-product-configuration');
const productConfiguration: IProductConfiguration = {
...element ? JSON.parse(element.getAttribute('data-settings')!) : {
const productConfiguration = {
...this.configuration.productConfiguration ? this.configuration.productConfiguration : {
version: '1.38.0-unknown',
nameLong: 'Unknown',
extensionAllowedProposedApi: [],
}, ...{ urlProtocol: '' }
};
} as IProductConfiguration;
return { _serviceBrand: undefined, ...productConfiguration };
}
@@ -280,6 +285,7 @@ class CodeRendererMain extends Disposable {
return joinPath(URI.revive(JSON.parse(remoteUserDataPath)), 'User');
}
}
return null;
}
}

View File

@@ -242,7 +242,7 @@ import { isMacintosh, isWindows, isLinux, isWeb } from 'vs/base/common/platform'
},
'workbench.octiconsUpdate.enabled': {
'type': 'boolean',
'default': true,
'default': false,
'description': nls.localize('workbench.octiconsUpdate.enabled', "Controls the visibility of the new Octicons style in the workbench.")
}
}