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

@@ -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;